Browse Source

Merge remote-tracking branch 'origin/master'

master
主管理员 3 days ago
parent
commit
ef29e9ff4d
30 changed files with 2418 additions and 70 deletions
  1. +12
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/pom.xml
  2. +16
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiIndexController.java
  3. +133
    -13
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiTTSController.java
  4. +5
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/AppletApiIndexService.java
  5. +15
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/AppletApiTTService.java
  6. +36
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiIndexServiceImpl.java
  7. +231
    -56
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiTTServiceImpl.java
  8. +207
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/controller/AppletArticleController.java
  9. +77
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/entity/AppletArticle.java
  10. +17
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/mapper/AppletArticleMapper.java
  11. +5
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/mapper/xml/AppletArticleMapper.xml
  12. +14
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/service/IAppletArticleService.java
  13. +19
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/service/impl/AppletArticleServiceImpl.java
  14. +101
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/uniapp/AppletArticleForm.vue
  15. +44
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/uniapp/AppletArticleList.vue
  16. +22
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/uniapp3/AppletArticleData.ts
  17. +253
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/uniapp3/AppletArticleForm.vue
  18. +148
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/uniapp3/AppletArticleList.vue
  19. +64
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/vue3/AppletArticle.api.ts
  20. +77
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/vue3/AppletArticle.data.ts
  21. +210
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/vue3/AppletArticleList.vue
  22. +26
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/vue3/V20251023_1__menu_insert_AppletArticle.sql
  23. +70
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/vue3/components/AppletArticleForm.vue
  24. +99
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/vue3/components/AppletArticleModal.vue
  25. +1
    -1
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletTtsCache/entity/AppletTtsCache.java
  26. +64
    -0
      jeecgboot-vue3/src/views/applet/article/AppletArticle.api.ts
  27. +77
    -0
      jeecgboot-vue3/src/views/applet/article/AppletArticle.data.ts
  28. +206
    -0
      jeecgboot-vue3/src/views/applet/article/AppletArticleList.vue
  29. +70
    -0
      jeecgboot-vue3/src/views/applet/article/components/AppletArticleForm.vue
  30. +99
    -0
      jeecgboot-vue3/src/views/applet/article/components/AppletArticleModal.vue

+ 12
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/pom.xml View File

@ -3,6 +3,18 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>jeecgboot-boot-applet</artifactId> <artifactId>jeecgboot-boot-applet</artifactId>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
</plugins>
</build>
<parent> <parent>
<artifactId>jeecg-boot-module</artifactId> <artifactId>jeecg-boot-module</artifactId>


+ 16
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiIndexController.java View File

@ -8,6 +8,7 @@ import org.jeecg.common.api.vo.Result;
import org.jeecg.config.shiro.IgnoreAuth; import org.jeecg.config.shiro.IgnoreAuth;
import org.jeecg.modules.applet.service.AppletApiConfigService; import org.jeecg.modules.applet.service.AppletApiConfigService;
import org.jeecg.modules.applet.service.AppletApiIndexService; import org.jeecg.modules.applet.service.AppletApiIndexService;
import org.jeecg.modules.demo.appletArticle.entity.AppletArticle;
import org.jeecg.modules.demo.appletBanner.entity.AppletBanner; import org.jeecg.modules.demo.appletBanner.entity.AppletBanner;
import org.jeecg.modules.demo.appletConfig.entity.AppletConfig; import org.jeecg.modules.demo.appletConfig.entity.AppletConfig;
import org.jeecg.modules.demo.appletLink.entity.AppletLink; import org.jeecg.modules.demo.appletLink.entity.AppletLink;
@ -49,6 +50,7 @@ public class AppletApiIndexController {
List<AppletBanner> list = appletApiIndexService.getBanner(); List<AppletBanner> list = appletApiIndexService.getBanner();
return Result.OK(list); return Result.OK(list);
} }
/** /**
* 轮播图详情 * 轮播图详情
* *
@ -87,4 +89,18 @@ public class AppletApiIndexController {
appletApiIndexService.linkSignup(appletRegistration); appletApiIndexService.linkSignup(appletRegistration);
return Result.OK(); return Result.OK();
} }
@IgnoreAuth
@Operation(summary = "查询文章列表", description = "查询文章列表")
@GetMapping(value = "/articleList")
public Result<List<AppletArticle>> articleList() {
return Result.OK(appletApiIndexService.articleList());
}
@IgnoreAuth
@Operation(summary = "查询文章详情", description = "查询文章详情")
@GetMapping(value = "/articleDetail")
public Result<AppletArticle> articleDetail(String id) {
return Result.OK(appletApiIndexService.articleDetail(id));
}
} }

+ 133
- 13
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiTTSController.java View File

@ -17,6 +17,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -122,23 +123,142 @@ public class AppletApiTTSController {
// } // }
@Operation(summary = "接收长文本TTS回调", description = "接收腾讯云回调并保存音频与状态") @Operation(summary = "接收长文本TTS回调", description = "接收腾讯云回调并保存音频与状态")
@PostMapping(value = "/long/callback")
@PostMapping(value = "/long/callback", consumes = {"application/json", "application/x-www-form-urlencoded", "text/plain"})
@IgnoreAuth @IgnoreAuth
public Result<Boolean> ttsCallback(@RequestBody Map<String, Object> payload) {
public Result<Boolean> ttsCallback(HttpServletRequest request) {
try { try {
log.info("回调内容: {}", payload);
String taskId = (String) payload.get("TaskId");
Boolean success = payload.get("Success") instanceof Boolean ? (Boolean) payload.get("Success") : null;
String audioBase64 = (String) payload.get("Audio");
Integer sampleRate = payload.get("SampleRate") instanceof Number ? ((Number) payload.get("SampleRate")).intValue() : null;
String codec = (String) payload.get("Codec");
String message = (String) payload.get("Message");
boolean ok = appletApiTTService.handleTtsCallback(taskId, audioBase64, sampleRate, codec, success != null && success, message);
String contentType = request.getContentType();
log.info("回调请求 Content-Type: {}", contentType);
String raw = null;
// 直接从 InputStream 读取原始字节避免 Spring 的参数解析
try (java.io.InputStream is = request.getInputStream()) {
byte[] bytes = is.readAllBytes();
raw = new String(bytes, java.nio.charset.StandardCharsets.UTF_8);
log.info("原始请求体长度: {} 字节", bytes.length);
}
if (raw == null || raw.trim().isEmpty()) {
log.error("请求体为空");
return Result.error("请求体为空");
}
log.info("原始请求体前200字符: {}", raw.length() > 200 ? raw.substring(0, 200) + "..." : raw);
String json = raw;
// 处理 form-urlencoded 格式
if (contentType != null && contentType.contains("application/x-www-form-urlencoded")) {
// 查找 data= 参数
int dataIdx = raw.indexOf("data=");
if (dataIdx >= 0) {
String encoded = raw.substring(dataIdx + 5);
// 处理可能存在的其他参数 & 分隔
int ampIdx = encoded.indexOf('&');
if (ampIdx > 0) {
encoded = encoded.substring(0, ampIdx);
}
try {
// 多次 URL 解码处理可能的双重编码
json = java.net.URLDecoder.decode(encoded, "UTF-8");
// 如果解码后仍然包含 %可能需要再次解码
if (json.contains("%")) {
try {
String doubleDecoded = java.net.URLDecoder.decode(json, "UTF-8");
if (doubleDecoded.trim().startsWith("{")) {
json = doubleDecoded;
}
} catch (Exception e) {
log.warn("二次URL解码失败,使用一次解码结果: {}", e.getMessage());
}
}
log.info("URL解码后的JSON前200字符: {}", json.length() > 200 ? json.substring(0, 200) + "..." : json);
} catch (Exception decodeEx) {
log.warn("URL解码失败,使用原始编码数据: {}", decodeEx.getMessage());
json = encoded;
}
}
} else if (raw.startsWith("data=")) {
// 处理直接以 data= 开头的情况
String encoded = raw.substring(5);
try {
json = java.net.URLDecoder.decode(encoded, "UTF-8");
log.info("直接data=格式解码后: {}", json.length() > 200 ? json.substring(0, 200) + "..." : json);
} catch (Exception decodeEx) {
log.warn("直接data=格式解码失败: {}", decodeEx.getMessage());
json = encoded;
}
}
// 解析 JSON
com.alibaba.fastjson.JSONObject obj = null;
// 清理可能的前后空白字符和引号
json = json.trim();
if (json.startsWith("\"") && json.endsWith("\"")) {
json = json.substring(1, json.length() - 1);
}
if (json.startsWith("{")) {
try {
obj = com.alibaba.fastjson.JSON.parseObject(json);
} catch (Exception parseEx) {
log.error("JSON解析失败: {}, JSON内容: {}", parseEx.getMessage(), json);
// 尝试提取 JSON 部分
int start = json.indexOf('{');
int end = json.lastIndexOf('}');
if (start >= 0 && end > start) {
try {
obj = com.alibaba.fastjson.JSON.parseObject(json.substring(start, end + 1));
} catch (Exception e2) {
log.error("提取JSON部分后仍解析失败: {}", e2.getMessage());
}
}
}
} else {
// 尝试查找 JSON 部分
int start = json.indexOf('{');
int end = json.lastIndexOf('}');
if (start >= 0 && end > start) {
try {
obj = com.alibaba.fastjson.JSON.parseObject(json.substring(start, end + 1));
} catch (Exception parseEx) {
log.error("提取JSON部分解析失败: {}", parseEx.getMessage());
}
}
}
if (obj == null) {
log.error("回调解析失败,无法提取有效JSON,原始内容: {}", json);
return Result.error("回调解析失败,非JSON格式");
}
log.info("成功解析回调JSON,TaskId: {}", obj.getString("TaskId"));
String taskId = obj.getString("TaskId");
Long status = obj.getLong("Status");
String statusStr = obj.getString("StatusStr");
String resultUrl = obj.getString("ResultUrl");
com.alibaba.fastjson.JSONArray subtitles = obj.getJSONArray("Subtitles");
String subtitlesJson = subtitles != null ? subtitles.toJSONString() : null;
// 清理URL中的反引号等异常字符
if (resultUrl != null) {
resultUrl = resultUrl.replace("`", "").trim();
log.info("清理后的ResultUrl: {}", resultUrl);
}
boolean ok = appletApiTTService.handleLongTextTtsCallback(taskId, resultUrl, status, statusStr, subtitlesJson);
return ok ? Result.OK(true) : Result.error("回调处理失败"); return ok ? Result.OK(true) : Result.error("回调处理失败");
} catch (Exception e) { } catch (Exception e) {
log.error("回调解析失败: {}", e.getMessage(), e);
return Result.error("回调解析失败: " + e.getMessage());
log.error("回调处理异常: {}", e.getMessage(), e);
return Result.error("回调处理异常: " + e.getMessage());
} }
} }


+ 5
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/AppletApiIndexService.java View File

@ -1,5 +1,6 @@
package org.jeecg.modules.applet.service; package org.jeecg.modules.applet.service;
import org.jeecg.modules.demo.appletArticle.entity.AppletArticle;
import org.jeecg.modules.demo.appletBanner.entity.AppletBanner; import org.jeecg.modules.demo.appletBanner.entity.AppletBanner;
import org.jeecg.modules.demo.appletLink.entity.AppletLink; import org.jeecg.modules.demo.appletLink.entity.AppletLink;
import org.jeecg.modules.demo.appletRegistration.entity.AppletRegistration; import org.jeecg.modules.demo.appletRegistration.entity.AppletRegistration;
@ -37,4 +38,8 @@ public interface AppletApiIndexService {
* @param appletRegistration * @param appletRegistration
*/ */
void linkSignup(AppletRegistration appletRegistration); void linkSignup(AppletRegistration appletRegistration);
List<AppletArticle> articleList();
AppletArticle articleDetail(String id);
} }

+ 15
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/AppletApiTTService.java View File

@ -6,6 +6,7 @@ import org.jeecg.modules.demo.appletTtsTimbre.entity.AppletTtsTimbre;
import org.jeecg.modules.demo.appletTtsCache.entity.AppletTtsCache; import org.jeecg.modules.demo.appletTtsCache.entity.AppletTtsCache;
import java.util.List; import java.util.List;
import java.util.Map;
public interface AppletApiTTService { public interface AppletApiTTService {
/** /**
@ -27,6 +28,11 @@ public interface AppletApiTTService {
*/ */
String createLongTextTtsTask(String text, Float speed, Integer voiceType, Float volume, String codec, String callbackUrl); String createLongTextTtsTask(String text, Float speed, Integer voiceType, Float volume, String codec, String callbackUrl);
/**
* 为文章内容遍历所有启用音色创建长文本TTS任务异步
*/
void generateLongTextForArticleContentAllTimbres(String content);
/** /**
* 按页面创建长文本TTS任务异步仅接收页面ID与音色ID * 按页面创建长文本TTS任务异步仅接收页面ID与音色ID
*/ */
@ -46,4 +52,13 @@ public interface AppletApiTTService {
* 接收腾讯云TTS异步回调并处理结果保存到缓存并更新状态 * 接收腾讯云TTS异步回调并处理结果保存到缓存并更新状态
*/ */
boolean handleTtsCallback(String taskId, String audioBase64, Integer sampleRate, String codec, boolean success, String message); boolean handleTtsCallback(String taskId, String audioBase64, Integer sampleRate, String codec, boolean success, String message);
/**
* 接收腾讯云长文本TTS异步回调并处理结果保存ResultUrl和字幕到缓存
*/
boolean handleLongTextTtsCallback(String taskId, String resultUrl, Long status, String statusStr, String subtitlesJson);
Map<Integer, Object> selectMapByHtml(String content);
} }

+ 36
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiIndexServiceImpl.java View File

@ -3,6 +3,9 @@ package org.jeecg.modules.applet.service.impl;
import org.jeecg.common.exception.JeecgBootException; import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.util.AppletUserUtil; import org.jeecg.common.system.util.AppletUserUtil;
import org.jeecg.modules.applet.service.AppletApiIndexService; import org.jeecg.modules.applet.service.AppletApiIndexService;
import org.jeecg.modules.applet.service.AppletApiTTService;
import org.jeecg.modules.demo.appletArticle.entity.AppletArticle;
import org.jeecg.modules.demo.appletArticle.service.IAppletArticleService;
import org.jeecg.modules.demo.appletBanner.entity.AppletBanner; import org.jeecg.modules.demo.appletBanner.entity.AppletBanner;
import org.jeecg.modules.demo.appletBanner.service.IAppletBannerService; import org.jeecg.modules.demo.appletBanner.service.IAppletBannerService;
import org.jeecg.modules.demo.appletCoursePage.entity.AppletCoursePage; import org.jeecg.modules.demo.appletCoursePage.entity.AppletCoursePage;
@ -14,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Map;
@Service @Service
public class AppletApiIndexServiceImpl implements AppletApiIndexService { public class AppletApiIndexServiceImpl implements AppletApiIndexService {
@ -27,6 +31,12 @@ public class AppletApiIndexServiceImpl implements AppletApiIndexService {
@Autowired @Autowired
private IAppletRegistrationService appletRegistrationService; private IAppletRegistrationService appletRegistrationService;
@Autowired
private IAppletArticleService appletArticleService;
@Autowired
private AppletApiTTService appletApiTTService;
/*** /***
* 轮播图 * 轮播图
* @return * @return
@ -87,4 +97,30 @@ public class AppletApiIndexServiceImpl implements AppletApiIndexService {
appletRegistrationService.save(appletRegistration); appletRegistrationService.save(appletRegistration);
} }
@Override
public List<AppletArticle> articleList() {
return appletArticleService
.lambdaQuery()
.orderByDesc(AppletArticle::getSort, AppletArticle::getCreateTime)
.eq(AppletArticle::getStatus, "Y")
.select(AppletArticle::getTitle, AppletArticle::getId)
.list();
}
@Override
public AppletArticle articleDetail(String id) {
AppletArticle byId = appletArticleService.getById(id);
if (byId == null){
return null;
}
//查询音频
Map<Integer, Object> map = appletApiTTService.selectMapByHtml(byId.getContent());
byId.setAudios(map);
return byId;
}
} }

+ 231
- 56
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiTTServiceImpl.java View File

@ -26,6 +26,7 @@ import org.jeecg.modules.demo.appletCoursePage.entity.AppletCoursePage;
import org.jeecg.modules.demo.appletCoursePage.service.IAppletCoursePageService; import org.jeecg.modules.demo.appletCoursePage.service.IAppletCoursePageService;
import org.jeecg.modules.demo.appletCoursePageWord.entity.AppletCoursePageWord; import org.jeecg.modules.demo.appletCoursePageWord.entity.AppletCoursePageWord;
import org.jeecg.modules.demo.appletCoursePageWord.service.IAppletCoursePageWordService; import org.jeecg.modules.demo.appletCoursePageWord.service.IAppletCoursePageWordService;
import org.jeecg.modules.demo.appletTtsPlayLog.entity.AppletTtsPlayLog;
import org.jeecg.modules.demo.appletTtsPlayLog.service.IAppletTtsPlayLogService; import org.jeecg.modules.demo.appletTtsPlayLog.service.IAppletTtsPlayLogService;
import org.jeecg.modules.demo.appletTtsTimbre.entity.AppletTtsTimbre; import org.jeecg.modules.demo.appletTtsTimbre.entity.AppletTtsTimbre;
import org.jeecg.modules.demo.appletTtsTimbre.service.IAppletTtsTimbreService; import org.jeecg.modules.demo.appletTtsTimbre.service.IAppletTtsTimbreService;
@ -35,11 +36,11 @@ import org.jeecg.modules.applet.util.AudioDurationUtil;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import java.util.concurrent.TimeUnit;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.UUID;
import java.util.Base64;
import java.util.*;
import java.net.URL; import java.net.URL;
import java.io.InputStream; import java.io.InputStream;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@ -65,6 +66,8 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
private IAppletCoursePageService appletCoursePageService; private IAppletCoursePageService appletCoursePageService;
@Autowired @Autowired
private IAppletCoursePageWordService appletCoursePageWordService; private IAppletCoursePageWordService appletCoursePageWordService;
@Autowired
private RedisTemplate<String, Object> redisTemplate;
public TtsVo textToVoice(String text, Float speed, Integer voiceType, Float volume, String codec) { public TtsVo textToVoice(String text, Float speed, Integer voiceType, Float volume, String codec) {
@ -78,23 +81,23 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
// 1. 先查询缓存数据库看是否已经有相同参数的音频 // 1. 先查询缓存数据库看是否已经有相同参数的音频
LambdaQueryWrapper<AppletTtsCache> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<AppletTtsCache> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AppletTtsCache::getText, text) queryWrapper.eq(AppletTtsCache::getText, text)
.eq(AppletTtsCache::getVoiceType, voiceType)
.eq(volume != null, AppletTtsCache::getVolume, volume != null ? volume.doubleValue() : null)
.eq(speed != null, AppletTtsCache::getSpeed, speed != null ? speed.doubleValue() : null)
.eq(AppletTtsCache::getSuccess, "Y");
.eq(AppletTtsCache::getVoiceType, voiceType)
.eq(volume != null, AppletTtsCache::getVolume, volume != null ? volume.doubleValue() : null)
.eq(speed != null, AppletTtsCache::getSpeed, speed != null ? speed.doubleValue() : null)
.eq(AppletTtsCache::getSuccess, "Y");
AppletTtsCache existingCache = appletTtsCacheService.getOne(queryWrapper); AppletTtsCache existingCache = appletTtsCacheService.getOne(queryWrapper);
if (existingCache != null) { if (existingCache != null) {
// 缓存命中直接返回缓存的音频ID // 缓存命中直接返回缓存的音频ID
log.info("TTS缓存命中,直接返回缓存音频,audioId: {}", existingCache.getAudioId()); log.info("TTS缓存命中,直接返回缓存音频,audioId: {}", existingCache.getAudioId());
// 记录播放日志 // 记录播放日志
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
double elapsedTime = (endTime - startTime) / 1000.0; double elapsedTime = (endTime - startTime) / 1000.0;
savePlayLog(userId, text, voiceType, volume != null ? volume.doubleValue() : null, savePlayLog(userId, text, voiceType, volume != null ? volume.doubleValue() : null,
speed != null ? speed.doubleValue() : null, elapsedTime, true, existingCache.getId());
speed != null ? speed.doubleValue() : null, elapsedTime, true, existingCache.getId());
return TtsVo.builder() return TtsVo.builder()
.url(existingCache.getAudioId()) .url(existingCache.getAudioId())
.time(existingCache.getDuration()) .time(existingCache.getDuration())
@ -103,7 +106,7 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
// 2. 缓存未命中调用腾讯云TTS接口生成音频 // 2. 缓存未命中调用腾讯云TTS接口生成音频
log.info("TTS缓存未命中,调用腾讯云接口生成音频"); log.info("TTS缓存未命中,调用腾讯云接口生成音频");
// 创建认证对象 // 创建认证对象
Credential cred = new Credential(secretId, secretKey); Credential cred = new Credential(secretId, secretKey);
@ -160,7 +163,7 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
// 3. 将音频数据上传到OSS // 3. 将音频数据上传到OSS
byte[] audioData = java.util.Base64.getDecoder().decode(audioBase64); byte[] audioData = java.util.Base64.getDecoder().decode(audioBase64);
String fileName = IdUtils.generateNo("TTS_") + System.currentTimeMillis() + ".wav"; String fileName = IdUtils.generateNo("TTS_") + System.currentTimeMillis() + ".wav";
// 使用ByteArrayInputStream上传到OSS // 使用ByteArrayInputStream上传到OSS
ByteArrayInputStream inputStream = new ByteArrayInputStream(audioData); ByteArrayInputStream inputStream = new ByteArrayInputStream(audioData);
String audioUrl = OssBootUtil.upload(inputStream, "tts/" + fileName); String audioUrl = OssBootUtil.upload(inputStream, "tts/" + fileName);
@ -200,7 +203,7 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
// 记录成功的TTS调用日志 // 记录成功的TTS调用日志
savePlayLog(userId, text, voiceType, volume != null ? volume.doubleValue() : null, savePlayLog(userId, text, voiceType, volume != null ? volume.doubleValue() : null,
speed != null ? speed.doubleValue() : null, elapsedTime, true, cacheId);
speed != null ? speed.doubleValue() : null, elapsedTime, true, cacheId);
log.info("TTS调用成功,文本长度: {}, 耗时: {}秒", text != null ? text.length() : 0, elapsedTime); log.info("TTS调用成功,文本长度: {}, 耗时: {}秒", text != null ? text.length() : 0, elapsedTime);
return TtsVo.builder() return TtsVo.builder()
@ -210,7 +213,7 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
} else { } else {
// 记录失败的TTS调用日志 // 记录失败的TTS调用日志
savePlayLog(userId, text, voiceType, volume != null ? volume.doubleValue() : null, savePlayLog(userId, text, voiceType, volume != null ? volume.doubleValue() : null,
speed != null ? speed.doubleValue() : null, elapsedTime, false, null);
speed != null ? speed.doubleValue() : null, elapsedTime, false, null);
log.warn("TTS返回的音频数据为空"); log.warn("TTS返回的音频数据为空");
return null; return null;
@ -223,22 +226,98 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
// 记录失败的TTS调用日志 // 记录失败的TTS调用日志
savePlayLog(userId, text, voiceType, volume != null ? volume.doubleValue() : null, savePlayLog(userId, text, voiceType, volume != null ? volume.doubleValue() : null,
speed != null ? speed.doubleValue() : null, elapsedTime, false, null);
speed != null ? speed.doubleValue() : null, elapsedTime, false, null);
log.error("调用腾讯云TTS接口失败: {}", e.getMessage(), e); log.error("调用腾讯云TTS接口失败: {}", e.getMessage(), e);
return null; return null;
} }
} }
@Override
public boolean handleLongTextTtsCallback(String taskId, String resultUrl, Long status, String statusStr, String subtitlesJson) {
// Redis锁的key
String lockKey = "tts_callback_lock:" + taskId;
// 锁的过期时间
int lockExpireTime = 300; // 5分钟
try {
// 尝试获取Redis分布式锁
Boolean lockAcquired = redisTemplate.opsForValue().setIfAbsent(lockKey, "locked", lockExpireTime, TimeUnit.SECONDS);
if (!lockAcquired) {
log.warn("TTS回调处理已在进行中,跳过重复处理,taskId: {}", taskId);
return false;
}
log.info("获取TTS回调处理锁成功,开始处理,taskId: {}", taskId);
// 检查数据库中是否已经处理完成
AppletTtsCache cache = appletTtsCacheService
.lambdaQuery()
.eq(AppletTtsCache::getTaskId, taskId)
.one();
if (cache == null) {
log.error("未找到对应的TTS缓存记录,taskId: {}", taskId);
return false;
}
// 如果已经处理完成成功状态且state=1直接返回
if ("Y".equals(cache.getSuccess()) && cache.getState() != null && cache.getState() == 1) {
log.info("TTS任务已处理完成,无需重复处理,taskId: {}, audioId: {}", taskId, cache.getAudioId());
return true;
}
// 保存字幕信息
if (subtitlesJson != null && !subtitlesJson.isEmpty()) {
cache.setSubtitlesJson(subtitlesJson);
}
// 判断是否成功 (Status == 2 表示成功)
if (status != null && status == 2) {
// 使用统一的音频处理方法
AudioProcessResult audioResult = processAndUploadAudio(resultUrl, taskId);
cache.setAudioId(audioResult.getAudioUrl());
if (audioResult.getDuration() != null) {
cache.setDuration(audioResult.getDuration());
}
cache.setSuccess("Y");
cache.setState(1);
} else {
cache.setSuccess("N");
cache.setState(0);
log.warn("TTS任务失败,taskId: {}, status: {}, statusStr: {}", taskId, status, statusStr);
}
cache.setUpdateTime(new java.util.Date());
appletTtsCacheService.updateById(cache);
log.info("长文本TTS回调处理完成,taskId: {}, success: {}, status: {}", taskId, cache.getSuccess(), status);
return true;
} catch (Exception e) {
log.error("处理长文本TTS回调失败: {}", e.getMessage(), e);
return false;
} finally {
// 释放Redis锁
try {
redisTemplate.delete(lockKey);
log.info("释放TTS回调处理锁,taskId: {}", taskId);
} catch (Exception e) {
log.error("释放TTS回调处理锁失败,taskId: {}, error: {}", taskId, e.getMessage());
}
}
}
@Override @Override
public String createLongTextTtsTask(String text, Float speed, Integer voiceType, Float volume, String codec, String callbackUrl) { public String createLongTextTtsTask(String text, Float speed, Integer voiceType, Float volume, String codec, String callbackUrl) {
try { try {
// 先检查是否存在生成中的任务相同文本与参数
// 将文章内容去除HTML并计算哈希用于缓存唯一标识
String normalized = stripHtml(text);
String textHash = String.valueOf(normalized.hashCode());
// 先检查是否存在生成中的任务相同文本哈希与音色
LambdaQueryWrapper<AppletTtsCache> generatingWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<AppletTtsCache> generatingWrapper = new LambdaQueryWrapper<>();
generatingWrapper.eq(AppletTtsCache::getText, text)
generatingWrapper.eq(AppletTtsCache::getText, textHash)
.eq(AppletTtsCache::getVoiceType, voiceType) .eq(AppletTtsCache::getVoiceType, voiceType)
.eq(volume != null, AppletTtsCache::getVolume, volume != null ? volume.doubleValue() : null)
.eq(speed != null, AppletTtsCache::getSpeed, speed != null ? speed.doubleValue() : null)
.eq(AppletTtsCache::getState, 0); .eq(AppletTtsCache::getState, 0);
AppletTtsCache generating = appletTtsCacheService.getOne(generatingWrapper); AppletTtsCache generating = appletTtsCacheService.getOne(generatingWrapper);
@ -249,10 +328,8 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
// 再检查是否已有成功缓存 // 再检查是否已有成功缓存
LambdaQueryWrapper<AppletTtsCache> successWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<AppletTtsCache> successWrapper = new LambdaQueryWrapper<>();
successWrapper.eq(AppletTtsCache::getText, text)
successWrapper.eq(AppletTtsCache::getText, textHash)
.eq(AppletTtsCache::getVoiceType, voiceType) .eq(AppletTtsCache::getVoiceType, voiceType)
.eq(volume != null, AppletTtsCache::getVolume, volume != null ? volume.doubleValue() : null)
.eq(speed != null, AppletTtsCache::getSpeed, speed != null ? speed.doubleValue() : null)
.eq(AppletTtsCache::getSuccess, "Y") .eq(AppletTtsCache::getSuccess, "Y")
.eq(AppletTtsCache::getState, 1); .eq(AppletTtsCache::getState, 1);
AppletTtsCache successCache = appletTtsCacheService.getOne(successWrapper); AppletTtsCache successCache = appletTtsCacheService.getOne(successWrapper);
@ -285,7 +362,8 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
// 启用时间戳字幕 // 启用时间戳字幕
try { try {
req.getClass().getMethod("setEnableSubtitle", Boolean.class).invoke(req, Boolean.TRUE); req.getClass().getMethod("setEnableSubtitle", Boolean.class).invoke(req, Boolean.TRUE);
} catch (Exception ignore) {}
} catch (Exception ignore) {
}
if (callbackUrl != null && !callbackUrl.isEmpty()) { if (callbackUrl != null && !callbackUrl.isEmpty()) {
req.setCallbackUrl(callbackUrl); req.setCallbackUrl(callbackUrl);
} }
@ -296,10 +374,10 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
throw new JeecgBootException("创建长文本TTS任务失败,未返回任务ID"); throw new JeecgBootException("创建长文本TTS任务失败,未返回任务ID");
} }
// 写入缓存标记生成中
// 写入缓存标记生成中text字段保存哈希
AppletTtsCache cache = new AppletTtsCache(); AppletTtsCache cache = new AppletTtsCache();
cache.setTaskId(taskId); cache.setTaskId(taskId);
cache.setText(text);
cache.setText(textHash);
cache.setVoiceType(voiceType); cache.setVoiceType(voiceType);
cache.setVolume(volume != null ? volume.doubleValue() : null); cache.setVolume(volume != null ? volume.doubleValue() : null);
cache.setSpeed(speed != null ? speed.doubleValue() : null); cache.setSpeed(speed != null ? speed.doubleValue() : null);
@ -308,7 +386,7 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
cache.setCreateTime(new java.util.Date()); cache.setCreateTime(new java.util.Date());
appletTtsCacheService.save(cache); appletTtsCacheService.save(cache);
log.info("长文本TTS任务创建成功,taskId: {}", taskId);
log.info("长文本TTS任务创建成功,taskId: {},textHash: {}", taskId, textHash);
return taskId; return taskId;
} catch (Exception e) { } catch (Exception e) {
log.error("创建长文本TTS任务失败: {}", e.getMessage(), e); log.error("创建长文本TTS任务失败: {}", e.getMessage(), e);
@ -352,32 +430,21 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
appletTtsCacheService.updateById(cache); appletTtsCacheService.updateById(cache);
return cache; return cache;
} else if (status == 2) { } else if (status == 2) {
// 成功处理音频
byte[] audioData = null;
if (audioUrl != null && !audioUrl.isEmpty()) {
audioData = downloadBytes(audioUrl);
}
if (audioData != null) {
String fileName = IdUtils.generateNo("TTS_") + System.currentTimeMillis() + ".wav";
ByteArrayInputStream inputStream = new ByteArrayInputStream(audioData);
String uploadedUrl = OssBootUtil.upload(inputStream, "tts/" + fileName);
cache.setAudioId(uploadedUrl != null ? uploadedUrl : audioUrl);
// 成功使用统一的音频处理方法
AudioProcessResult audioResult = processAndUploadAudio(audioUrl, taskId);
Double realDuration = AudioDurationUtil.calculateDuration(audioData);
if (realDuration != null) {
cache.setDuration(realDuration);
}
} else {
cache.setAudioId(audioUrl);
cache.setAudioId(audioResult.getAudioUrl());
if (audioResult.getDuration() != null) {
cache.setDuration(audioResult.getDuration());
} }
// 解析时间戳 // 解析时间戳
String timestampsJson = null; String timestampsJson = null;
try { try {
timestampsJson = JSON.toJSONString(resp.getData().getSubtitles()); timestampsJson = JSON.toJSONString(resp.getData().getSubtitles());
cache.setTimestamps(timestampsJson);
} catch (Exception ignore) {}
cache.setSubtitlesJson(timestampsJson);
} catch (Exception ignore) {
}
cache.setSuccess("Y"); cache.setSuccess("Y");
cache.setState(1); cache.setState(1);
@ -538,7 +605,8 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
String text = obj.getString("content"); String text = obj.getString("content");
return text != null ? text : ""; return text != null ? text : "";
} }
} catch (Exception ignore) {}
} catch (Exception ignore) {
}
// 作为纯文本返回 // 作为纯文本返回
return content; return content;
} }
@ -607,6 +675,31 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
} }
} }
@Override
public Map<Integer, Object> selectMapByHtml(String content) {
HashMap<Integer, Object> map = new HashMap<>();
int i = stripHtml(content).hashCode();
String textHash = String.valueOf(i);
List<AppletTtsTimbre> list = appletTtsTimbreService
.lambdaQuery()
.select(AppletTtsTimbre::getVoiceType)
.list();
for (AppletTtsTimbre timbre : list) {
AppletTtsCache one = appletTtsCacheService.lambdaQuery()
.eq(AppletTtsCache::getText, textHash)
.eq(AppletTtsCache::getVoiceType, timbre.getVoiceType())
.select(AppletTtsCache::getAudioId)
.one();
map.put(timbre.getVoiceType(), one != null ? one.getAudioId() : null);
}
return map;
}
private byte[] downloadBytes(String url) { private byte[] downloadBytes(String url) {
try (InputStream in = new URL(url).openStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream()) { try (InputStream in = new URL(url).openStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
byte[] buf = new byte[8192]; byte[] buf = new byte[8192];
@ -620,16 +713,14 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
return null; return null;
} }
} }
/** /**
* 保存TTS播放日志 * 保存TTS播放日志
*/ */
private void savePlayLog(String userId, String text, Integer voiceType, Double volume,
Double speed, Double elapsedTime, boolean success, String cacheId) {
private void savePlayLog(String userId, String text, Integer voiceType, Double volume,
Double speed, Double elapsedTime, boolean success, String cacheId) {
try { try {
org.jeecg.modules.demo.appletTtsPlayLog.entity.AppletTtsPlayLog playLog =
new org.jeecg.modules.demo.appletTtsPlayLog.entity.AppletTtsPlayLog();
AppletTtsPlayLog playLog = new AppletTtsPlayLog();
playLog.setUserId(userId); playLog.setUserId(userId);
playLog.setVoicetype(voiceType); playLog.setVoicetype(voiceType);
playLog.setVolume(volume); playLog.setVolume(volume);
@ -640,7 +731,7 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
playLog.setCreateTime(new java.util.Date()); playLog.setCreateTime(new java.util.Date());
appletTtsPlayLogService.save(playLog); appletTtsPlayLogService.save(playLog);
log.debug("TTS播放日志保存成功,用户: {}, 结果: {}, 缓存ID: {}", userId, success ? "成功" : "失败", cacheId); log.debug("TTS播放日志保存成功,用户: {}, 结果: {}, 缓存ID: {}", userId, success ? "成功" : "失败", cacheId);
} catch (Exception e) { } catch (Exception e) {
log.error("保存TTS播放日志失败: {}", e.getMessage(), e); log.error("保存TTS播放日志失败: {}", e.getMessage(), e);
@ -653,4 +744,88 @@ public class AppletApiTTServiceImpl implements AppletApiTTService {
return appletTtsTimbreService.list(); return appletTtsTimbreService.list();
} }
}
@Override
public void generateLongTextForArticleContentAllTimbres(String content) {
try {
List<AppletTtsTimbre> timbres = appletTtsTimbreService
.lambdaQuery()
.eq(AppletTtsTimbre::getStatus, "Y")
.select(AppletTtsTimbre::getVoiceType)
.list();
String callbackUrl = TtscallbackUrl;
for (AppletTtsTimbre timbre : timbres) {
try {
createLongTextTtsTask(content, null, timbre.getVoiceType(), null, "wav", callbackUrl);
} catch (Exception ex) {
log.warn("创建文章内容长文本TTS任务失败 voiceType {}: {}", timbre.getVoiceType(), ex.getMessage());
}
}
} catch (Exception e) {
log.error("遍历音色创建文章长文本TTS任务失败: {}", e.getMessage(), e);
}
}
/**
* 统一的音频处理方法下载音频上传到OSS计算时长
*
* @param audioUrl 音频URL
* @param taskId 任务ID用于日志
* @return AudioProcessResult 包含上传后的URL和音频时长
*/
private AudioProcessResult processAndUploadAudio(String audioUrl, String taskId) {
if (audioUrl == null || audioUrl.isEmpty()) {
log.warn("音频URL为空,taskId: {}", taskId);
return new AudioProcessResult(null, null);
}
try {
// 下载音频数据
byte[] audioData = downloadBytes(audioUrl);
if (audioData == null || audioData.length == 0) {
log.error("音频下载失败或数据为空,taskId: {}, audioUrl: {}", taskId, audioUrl);
return new AudioProcessResult(audioUrl, null); // 返回原始URL作为兜底
}
// 生成文件名并上传到OSS
String fileName = IdUtils.generateNo("TTS_") + System.currentTimeMillis() + ".wav";
ByteArrayInputStream inputStream = new ByteArrayInputStream(audioData);
String uploadedUrl = OssBootUtil.upload(inputStream, "tts/" + fileName);
if (uploadedUrl == null) {
log.error("音频上传到OSS失败,taskId: {}", taskId);
return new AudioProcessResult(audioUrl, null); // 返回原始URL作为兜底
}
// 计算音频时长
// Double audioDuration = AudioDurationUtil.calculateDuration(audioData);
log.info("音频处理成功,taskId: {}, uploadedUrl: {}, duration: {}", taskId, uploadedUrl, null);
return new AudioProcessResult(uploadedUrl, null);
} catch (Exception e) {
log.error("音频处理失败,taskId: {}, audioUrl: {}, error: {}", taskId, audioUrl, e.getMessage());
return new AudioProcessResult(audioUrl, null); // 返回原始URL作为兜底
}
}
/**
* 音频处理结果封装类
*/
private static class AudioProcessResult {
private final String audioUrl;
private final Double duration;
public AudioProcessResult(String audioUrl, Double duration) {
this.audioUrl = audioUrl;
this.duration = duration;
}
public String getAudioUrl() {
return audioUrl;
}
public Double getDuration() {
return duration;
}
}
}

+ 207
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/controller/AppletArticleController.java View File

@ -0,0 +1,207 @@
package org.jeecg.modules.demo.appletArticle.controller;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.demo.appletArticle.entity.AppletArticle;
import org.jeecg.modules.demo.appletArticle.service.IAppletArticleService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import com.alibaba.fastjson.JSON;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.modules.applet.service.AppletApiTTService;
/**
* @Description: 小程序文章
* @Author: jeecg-boot
* @Date: 2025-10-23
* @Version: V1.0
*/
@Tag(name="小程序文章")
@RestController
@RequestMapping("/appletArticle/appletArticle")
@Slf4j
public class AppletArticleController extends JeecgController<AppletArticle, IAppletArticleService> {
@Autowired
private IAppletArticleService appletArticleService;
@Autowired
private AppletApiTTService appletApiTTService;
/**
* 分页列表查询
*
* @param appletArticle
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "小程序文章-分页列表查询")
@Operation(summary="小程序文章-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<AppletArticle>> queryPageList(AppletArticle appletArticle,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<AppletArticle> queryWrapper = QueryGenerator.initQueryWrapper(appletArticle, req.getParameterMap());
Page<AppletArticle> page = new Page<AppletArticle>(pageNo, pageSize);
IPage<AppletArticle> pageList = appletArticleService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
* 添加
*
* @param appletArticle
* @return
*/
@AutoLog(value = "小程序文章-添加")
@Operation(summary="小程序文章-添加")
@RequiresPermissions("appletArticle:applet_article:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody AppletArticle appletArticle) {
appletArticleService.save(appletArticle);
// 触发长文本TTS生成遍历所有启用音色对content进行转换
try {
String content = appletArticle.getContent();
if (content != null && !content.trim().isEmpty()) {
appletApiTTService.generateLongTextForArticleContentAllTimbres(content);
}
} catch (Exception e) {
log.warn("文章添加后触发长文本TTS失败: {}", e.getMessage());
}
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param appletArticle
* @return
*/
@AutoLog(value = "小程序文章-编辑")
@Operation(summary="小程序文章-编辑")
@RequiresPermissions("appletArticle:applet_article:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody AppletArticle appletArticle) {
appletArticleService.updateById(appletArticle);
// 触发长文本TTS生成遍历所有启用音色对content进行转换
try {
String content = appletArticle.getContent();
if (content != null && !content.trim().isEmpty()) {
appletApiTTService.generateLongTextForArticleContentAllTimbres(content);
}
} catch (Exception e) {
log.warn("文章编辑后触发长文本TTS失败: {}", e.getMessage());
}
return Result.OK("编辑成功!");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "小程序文章-通过id删除")
@Operation(summary="小程序文章-通过id删除")
@RequiresPermissions("appletArticle:applet_article:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
appletArticleService.removeById(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "小程序文章-批量删除")
@Operation(summary="小程序文章-批量删除")
@RequiresPermissions("appletArticle:applet_article:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
this.appletArticleService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 通过id查询
*
* @param id
* @return
*/
//@AutoLog(value = "小程序文章-通过id查询")
@Operation(summary="小程序文章-通过id查询")
@GetMapping(value = "/queryById")
public Result<AppletArticle> queryById(@RequestParam(name="id",required=true) String id) {
AppletArticle appletArticle = appletArticleService.getById(id);
if(appletArticle==null) {
return Result.error("未找到对应数据");
}
return Result.OK(appletArticle);
}
/**
* 导出excel
*
* @param request
* @param appletArticle
*/
@RequiresPermissions("appletArticle:applet_article:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, AppletArticle appletArticle) {
return super.exportXls(request, appletArticle, AppletArticle.class, "小程序文章");
}
/**
* 通过excel导入数据
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("appletArticle:applet_article:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, AppletArticle.class);
}
}

+ 77
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/entity/AppletArticle.java View File

@ -0,0 +1,77 @@
package org.jeecg.modules.demo.appletArticle.entity;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.util.Date;
import java.math.BigDecimal;
import java.util.Map;
import com.baomidou.mybatisplus.annotation.*;
import org.jeecg.common.constant.ProvinceCityArea;
import org.jeecg.common.util.SpringContextUtils;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: 小程序文章
* @Author: jeecg-boot
* @Date: 2025-10-23
* @Version: V1.0
*/
@Data
@TableName("applet_article")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description="小程序文章")
public class AppletArticle implements Serializable {
private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private java.lang.String id;
/**创建人*/
@Schema(description = "创建人")
private java.lang.String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建日期")
private java.util.Date createTime;
/**更新人*/
@Schema(description = "更新人")
private java.lang.String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新日期")
private java.util.Date updateTime;
/**所属部门*/
@Schema(description = "所属部门")
private java.lang.String sysOrgCode;
/**标题*/
@Excel(name = "标题", width = 15)
@Schema(description = "标题")
private java.lang.String title;
/**排序*/
@Excel(name = "排序", width = 15)
@Schema(description = "排序")
private java.lang.Integer sort;
/**上架*/
@Excel(name = "上架", width = 15,replace = {"是_Y","否_N"} )
@Schema(description = "上架")
private java.lang.String status;
/**内容*/
@Excel(name = "内容", width = 15)
@Schema(description = "内容")
private java.lang.String content;
@TableField(exist = false)
private Map<Integer, Object> audios;
}

+ 17
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/mapper/AppletArticleMapper.java View File

@ -0,0 +1,17 @@
package org.jeecg.modules.demo.appletArticle.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.jeecg.modules.demo.appletArticle.entity.AppletArticle;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 小程序文章
* @Author: jeecg-boot
* @Date: 2025-10-23
* @Version: V1.0
*/
public interface AppletArticleMapper extends BaseMapper<AppletArticle> {
}

+ 5
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/mapper/xml/AppletArticleMapper.xml View File

@ -0,0 +1,5 @@
<?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="org.jeecg.modules.demo.appletArticle.mapper.AppletArticleMapper">
</mapper>

+ 14
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/service/IAppletArticleService.java View File

@ -0,0 +1,14 @@
package org.jeecg.modules.demo.appletArticle.service;
import org.jeecg.modules.demo.appletArticle.entity.AppletArticle;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 小程序文章
* @Author: jeecg-boot
* @Date: 2025-10-23
* @Version: V1.0
*/
public interface IAppletArticleService extends IService<AppletArticle> {
}

+ 19
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/service/impl/AppletArticleServiceImpl.java View File

@ -0,0 +1,19 @@
package org.jeecg.modules.demo.appletArticle.service.impl;
import org.jeecg.modules.demo.appletArticle.entity.AppletArticle;
import org.jeecg.modules.demo.appletArticle.mapper.AppletArticleMapper;
import org.jeecg.modules.demo.appletArticle.service.IAppletArticleService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 小程序文章
* @Author: jeecg-boot
* @Date: 2025-10-23
* @Version: V1.0
*/
@Service
public class AppletArticleServiceImpl extends ServiceImpl<AppletArticleMapper, AppletArticle> implements IAppletArticleService {
}

+ 101
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/uniapp/AppletArticleForm.vue View File

@ -0,0 +1,101 @@
<template>
<view>
<!--标题和返回-->
<cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
<block slot="backText">返回</block>
<block slot="content">小程序文章</block>
</cu-custom>
<!--表单区域-->
<view>
<form>
<view class="cu-form-group">
<view class="flex align-center">
<view class="title"><text space="ensp">标题</text></view>
<input placeholder="请输入标题" v-model="model.title"/>
</view>
</view>
<view class="cu-form-group">
<view class="flex align-center">
<view class="title"><text space="ensp">排序</text></view>
<input type="number" placeholder="请输入排序" v-model="model.sort"/>
</view>
</view>
<view class="cu-form-group">
<view class="flex align-center">
<view class="title"><text space="ensp">上架</text></view>
<input placeholder="请输入上架" v-model="model.status"/>
</view>
</view>
<view class="cu-form-group">
<view class="flex align-center">
<view class="title"><text space="ensp">内容</text></view>
<input placeholder="请输入内容" v-model="model.content"/>
</view>
</view>
<view class="padding">
<button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
<text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
</button>
</view>
</form>
</view>
</view>
</template>
<script>
import myDate from '@/components/my-componets/my-date.vue'
export default {
name: "AppletArticleForm",
components:{ myDate },
props:{
formData:{
type:Object,
default:()=>{},
required:false
}
},
data(){
return {
CustomBar: this.CustomBar,
NavBarColor: this.NavBarColor,
loading:false,
model: {},
backRouteName:'index',
url: {
queryById: "/appletArticle/appletArticle/queryById",
add: "/appletArticle/appletArticle/add",
edit: "/appletArticle/appletArticle/edit",
},
}
},
created(){
this.initFormData();
},
methods:{
initFormData(){
if(this.formData){
let dataId = this.formData.dataId;
this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
if(res.data.success){
console.log("表单数据",res);
this.model = res.data.result;
}
})
}
},
onSubmit() {
let myForm = {...this.model};
this.loading = true;
let url = myForm.id?this.url.edit:this.url.add;
this.$http.post(url,myForm).then(res=>{
console.log("res",res)
this.loading = false
this.$Router.push({name:this.backRouteName})
}).catch(()=>{
this.loading = false
});
}
}
}
</script>

+ 44
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/uniapp/AppletArticleList.vue View File

@ -0,0 +1,44 @@
<template>
<view>
<!--标题和返回-->
<cu-custom :bgColor="NavBarColor" isBack>
<block slot="backText">返回</block>
<block slot="content">小程序文章</block>
</cu-custom>
<!--滚动加载列表-->
<mescroll-body ref="mescrollRef" bottom="88" @init="mescrollInit" :up="upOption" :down="downOption" @down="downCallback" @up="upCallback">
<view class="cu-list menu">
<view class="cu-item" v-for="(item,index) in list" :key="index" @click="goHome">
<view class="flex" style="width:100%">
<text class="text-lg" style="color: #000;">
{{ item.createBy}}
</text>
</view>
</view>
</view>
</mescroll-body>
</view>
</template>
<script>
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
import Mixin from "@/common/mixin/Mixin.js";
export default {
name: '小程序文章',
mixins: [MescrollMixin,Mixin],
data() {
return {
CustomBar:this.CustomBar,
NavBarColor:this.NavBarColor,
url: "/appletArticle/appletArticle/list",
};
},
methods: {
goHome(){
this.$Router.push({name: "index"})
}
}
}
</script>

+ 22
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/uniapp3/AppletArticleData.ts View File

@ -0,0 +1,22 @@
import { render } from '@/common/renderUtils';
//列表数据
export const columns = [
{
title: '标题',
align:"center",
dataIndex: 'title'
},
{
title: '排序',
align:"center",
dataIndex: 'sort'
},
{
title: '上架',
align:"center",
dataIndex: 'status',
customRender:({text}) => {
return render.renderSwitch(text, [{text:'是',value:'Y'},{text:'否',value:'N'}])
},
},
];

+ 253
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/uniapp3/AppletArticleForm.vue View File

@ -0,0 +1,253 @@
<route lang="json5" type="page">
{
layout: 'default',
style: {
navigationStyle: 'custom',
navigationBarTitleText: '小程序文章',
},
}
</route>
<template>
<PageLayout :navTitle="navTitle" :backRouteName="backRouteName">
<scroll-view class="scrollArea" scroll-y>
<view class="form-container">
<wd-form ref="form" :model="myFormData">
<wd-cell-group border>
<view class="{ 'mt-14px': 0 == 0 }">
<wd-input
label-width="100px"
v-model="myFormData['title']"
:label="get4Label('标题')"
name='title'
prop='title'
placeholder="请选择标题"
:rules="[
]"
clearable
/>
</view>
<view class="{ 'mt-14px': 1 == 0 }">
<wd-input
label-width="100px"
v-model="myFormData['sort']"
:label="get4Label('排序')"
name='sort'
prop='sort'
placeholder="请选择排序"
inputMode="numeric"
:rules="[
]"
clearable
/>
</view>
<view class="{ 'mt-14px': 0 == 0 }">
<!-- 开关 -->
<wd-cell
:label="get4Label('上架')"
name='status'
title-width="100px"
center
>
<wd-switch
:label="get4Label('上架')"
name='status'
size="18px"
v-model="myFormData['status']"
active-value="Y"
inactive-value="N"
/>
</wd-cell>
</view>
<view class="{ 'mt-14px': 1 == 0 }">
<wd-textarea
:label="get4Label('内容')"
labelWidth="100px"
type="umeditor"
name='content'
prop='content'
clearable
:maxlength="300"
v-model="myFormData['content']"
></wd-textarea>
</view>
</wd-cell-group>
</wd-form>
</view>
</scroll-view>
<view class="footer">
<wd-button :disabled="loading" block :loading="loading" @click="handleSubmit">提交</wd-button>
</view>
</PageLayout>
</template>
<script lang="ts" setup>
import { onLoad } from '@dcloudio/uni-app'
import { http } from '@/utils/http'
import { useToast } from 'wot-design-uni'
import { useRouter } from '@/plugin/uni-mini-router'
import { ref, onMounted, computed,reactive } from 'vue'
import OnlineImage from '@/components/online/view/online-image.vue'
import OnlineFile from '@/components/online/view/online-file.vue'
import OnlineFileCustom from '@/components/online/view/online-file-custom.vue'
import OnlineSelect from '@/components/online/view/online-select.vue'
import OnlineTime from '@/components/online/view/online-time.vue'
import OnlineDate from '@/components/online/view/online-date.vue'
import OnlineRadio from '@/components/online/view/online-radio.vue'
import OnlineCheckbox from '@/components/online/view/online-checkbox.vue'
import OnlineMulti from '@/components/online/view/online-multi.vue'
import OnlinePopupLinkRecord from '@/components/online/view/online-popup-link-record.vue'
import OnlinePca from '@/components/online/view/online-pca.vue'
import SelectDept from '@/components/SelectDept/SelectDept.vue'
import SelectUser from '@/components/SelectUser/SelectUser.vue'
import {duplicateCheck} from "@/service/api";
defineOptions({
name: 'AppletArticleForm',
options: {
styleIsolation: 'shared',
},
})
const toast = useToast()
const router = useRouter()
const form = ref(null)
//
const myFormData = reactive({})
const loading = ref(false)
const navTitle = ref('新增')
const dataId = ref('')
const backRouteName = ref('AppletArticleList')
// initForm
const initForm = (item) => {
console.log('initForm item', item)
if(item?.dataId){
dataId.value = item.dataId;
navTitle.value = item.dataId?'编辑':'新增';
initData();
}
}
//
const initData = () => {
http.get("/appletArticle/appletArticle/queryById",{id:dataId.value}).then((res) => {
if (res.success) {
let obj = res.result
Object.assign(myFormData, { ...obj })
}else{
toast.error(res?.message || '表单加载失败!')
}
})
}
const handleSuccess = () => {
uni.$emit('refreshList');
router.back()
}
/**
* 校验唯一
* @param values
* @returns {boolean}
*/
async function fieldCheck(values: any) {
const onlyField = [
];
for (const field of onlyField) {
if (values[field]) {
//
const res: any = await duplicateCheck({
tableName: 'applet_article',
fieldName: field, // 使
fieldVal: values[field],
dataId: values.id,
});
if (!res.success) {
toast.warning(res.message);
return true; //
}
}
}
return false; //
}
//
const handleSubmit = async () => {
//
if (await fieldCheck(myFormData)) {
return
}
let url = dataId.value?'/appletArticle/appletArticle/edit':'/appletArticle/appletArticle/add';
form.value
.validate()
.then(({ valid, errors }) => {
if (valid) {
loading.value = true;
http.post(url,myFormData).then((res) => {
loading.value = false;
if (res.success) {
toast.success('保存成功');
handleSuccess()
}else{
toast.error(res?.message || '表单保存失败!')
}
})
}
})
.catch((error) => {
console.log(error, 'error')
loading.value = false;
})
}
//
const get4Label = computed(() => {
return (label) => {
return label && label.length > 4 ? label.substring(0, 4) : label;
}
})
//
const getFormSchema = computed(() => {
return (dictTable,dictCode,dictText) => {
return {
dictCode,
dictTable,
dictText
};
}
})
/**
* 获取日期控件的扩展类型
* @param picker
* @returns {string}
*/
const getDateExtendType = (picker: string) => {
let mapField = {
month: 'year-month',
year: 'year',
quarter: 'quarter',
week: 'week',
day: 'date',
}
return picker && mapField[picker]
? mapField[picker]
: 'date'
}
//pop
const setFieldsValue = (data) => {
Object.assign(myFormData, {...data })
}
// onLoad
onLoad((option) => {
initForm(option)
})
</script>
<style lang="scss" scoped>
.footer {
width: 100%;
padding: 10px 20px;
padding-bottom: calc(constant(safe-area-inset-bottom) + 10px);
padding-bottom: calc(env(safe-area-inset-bottom) + 10px);
}
:deep(.wd-cell__label) {
font-size: 14px;
color: #444;
}
:deep(.wd-cell__value) {
text-align: left;
}
</style>

+ 148
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/uniapp3/AppletArticleList.vue View File

@ -0,0 +1,148 @@
<route lang="json5" type="page">
{
layout: 'default',
style: {
navigationBarTitleText: '小程序文章',
navigationStyle: 'custom',
},
}
</route>
<template>
<PageLayout navTitle="小程序文章" backRouteName="index" routeMethod="pushTab">
<view class="wrap">
<z-paging
ref="paging"
:fixed="false"
v-model="dataList"
@query="queryList"
:default-page-size="15"
>
<template v-for="item in dataList" :key="item.id">
<wd-swipe-action>
<view class="list" @click="handleEdit(item)">
<template v-for="(cItem, cIndex) in columns" :key="cIndex">
<view v-if="cIndex < 3" class="box" :style="getBoxStyle">
<view class="field ellipsis">{{ cItem.title }}</view>
<view class="value cu-text-grey">{{ item[cItem.dataIndex] }}</view>
</view>
</template>
</view>
<template #right>
<view class="action">
<view class="button" @click="handleAction('del', item)">删除</view>
</view>
</template>
</wd-swipe-action>
</template>
</z-paging>
<view class="add u-iconfont u-icon-add" @click="handleAdd"></view>
</view>
</PageLayout>
</template>
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { http } from '@/utils/http'
import usePageList from '@/hooks/usePageList'
import {columns} from './AppletArticleData';
defineOptions({
name: 'AppletArticleList',
options: {
styleIsolation: 'shared',
}
})
//
let { toast, router, paging, dataList, queryList } = usePageList('/appletArticle/appletArticle/list');
//
const getBoxStyle = computed(() => {
return { width: "calc(33% - 5px)" }
})
//
const handleAction = (val, item) => {
if (val == 'del') {
http.delete("/appletArticle/appletArticle/delete?id="+item.id,{id:item.id}).then((res) => {
toast.success('删除成功~')
paging.value.reload()
})
}
}
// go
const handleAdd = () => {
router.push({
name: 'AppletArticleForm'
})
}
//go
const handleEdit = (record) => {
router.push({
name: 'AppletArticleForm',
params: {dataId: record.id},
})
}
onMounted(() => {
//
uni.$on('refreshList', () => {
queryList(1,10)
})
})
</script>
<style lang="scss" scoped>
.wrap {
height: 100%;
}
:deep(.wd-swipe-action) {
margin-top: 10px;
background-color: #fff;
}
.list {
padding: 10px 10px;
width: 100%;
text-align: left;
display: flex;
justify-content: space-between;
.box {
width: 33%;
.field {
margin-bottom: 10px;
line-height: 20px;
}
}
}
.action {
width: 60px;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
.button {
display: flex;
align-items: center;
justify-content: center;
flex: 1;
height: 100%;
color: #fff;
&:first-child {
background-color: #fa4350;
}
}
}
.add {
height: 70upx;
width: 70upx;
text-align: center;
line-height: 70upx;
background-color: #fff;
border-radius: 50%;
position: fixed;
bottom: 80upx;
right: 30upx;
box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.1);
color: #666;
}
</style>

+ 64
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/vue3/AppletArticle.api.ts View File

@ -0,0 +1,64 @@
import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
const { createConfirm } = useMessage();
enum Api {
list = '/appletArticle/appletArticle/list',
save='/appletArticle/appletArticle/add',
edit='/appletArticle/appletArticle/edit',
deleteOne = '/appletArticle/appletArticle/delete',
deleteBatch = '/appletArticle/appletArticle/deleteBatch',
importExcel = '/appletArticle/appletArticle/importExcel',
exportXls = '/appletArticle/appletArticle/exportXls',
}
/**
* api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
* api
*/
export const getImportUrl = Api.importExcel;
/**
*
* @param params
*/
export const list = (params) =>
defHttp.get({url: Api.list, params});
/**
*
*/
export const deleteOne = (params,handleSuccess) => {
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
/**
*
* @param params
*/
export const batchDelete = (params, handleSuccess) => {
createConfirm({
iconType: 'warning',
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
});
}
/**
*
* @param params
*/
export const saveOrUpdate = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.save;
return defHttp.post({url: url, params});
}

+ 77
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/vue3/AppletArticle.data.ts View File

@ -0,0 +1,77 @@
import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
{
title: '标题',
align:"center",
dataIndex: 'title'
},
{
title: '排序',
align:"center",
dataIndex: 'sort'
},
{
title: '上架',
align:"center",
dataIndex: 'status',
customRender:({text}) => {
return render.renderSwitch(text, [{text:'是',value:'Y'},{text:'否',value:'N'}])
},
},
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
{
label: '标题',
field: 'title',
component: 'Input',
},
{
label: '排序',
field: 'sort',
component: 'InputNumber',
},
{
label: '上架',
field: 'status',
component: 'JSwitch',
componentProps:{
},
},
{
label: '内容',
field: 'content',
component: 'JEditor',
},
// TODO 主键隐藏字段,目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false
},
];
// 高级查询数据
export const superQuerySchema = {
title: {title: '标题',order: 0,view: 'text', type: 'string',},
sort: {title: '排序',order: 1,view: 'number', type: 'number',},
status: {title: '上架',order: 2,view: 'switch', type: 'string',},
};
/**
* formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
// 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
return formSchema;
}

+ 210
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/vue3/AppletArticleList.vue View File

@ -0,0 +1,210 @@
<template>
<div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" v-auth="'appletArticle:applet_article:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" v-auth="'appletArticle:applet_article:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" v-auth="'appletArticle:applet_article:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon>
删除
</a-menu-item>
</a-menu>
</template>
<a-button v-auth="'appletArticle:applet_article:deleteBatch'">批量操作
<Icon icon="mdi:chevron-down"></Icon>
</a-button>
</a-dropdown>
<!-- 高级查询 -->
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
</template>
<!--字段回显插槽-->
<template v-slot:bodyCell="{ column, record, index, text }">
<template v-if="column.dataIndex==='content'">
<!--富文本件字段回显插槽-->
<div v-html="text"></div>
</template>
</template>
</BasicTable>
<!-- 表单区域 -->
<AppletArticleModal @register="registerModal" @success="handleSuccess"></AppletArticleModal>
</div>
</template>
<script lang="ts" name="appletArticle-appletArticle" setup>
import {ref, reactive, computed, unref} from 'vue';
import {BasicTable, useTable, TableAction} from '/@/components/Table';
import {useModal} from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage'
import AppletArticleModal from './components/AppletArticleModal.vue'
import {columns, searchFormSchema, superQuerySchema} from './AppletArticle.data';
import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './AppletArticle.api';
import { downloadFile } from '/@/utils/common/renderUtils';
import { useUserStore } from '/@/store/modules/user';
import { useMessage } from '/@/hooks/web/useMessage';
import { getDateByPicker } from '/@/utils';
//
const fieldPickers = reactive({
});
const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]);
const userStore = useUserStore();
const { createMessage } = useMessage();
//model
const [registerModal, {openModal}] = useModal();
//table
const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
tableProps:{
title: '小程序文章',
api: list,
columns,
canResize:true,
formConfig: {
//labelWidth: 120,
schemas: searchFormSchema,
autoSubmitOnEnter:true,
showAdvancedButton:true,
fieldMapToNumber: [
],
fieldMapToTime: [
],
},
actionColumn: {
width: 120,
fixed:'right'
},
beforeFetch: (params) => {
if (params && fieldPickers) {
for (let key in fieldPickers) {
if (params[key]) {
params[key] = getDateByPicker(params[key], fieldPickers[key]);
}
}
}
return Object.assign(params, queryParam);
},
},
exportConfig: {
name:"小程序文章",
url: getExportUrl,
params: queryParam,
},
importConfig: {
url: getImportUrl,
success: handleSuccess
},
})
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
//
const superQueryConfig = reactive(superQuerySchema);
/**
* 高级查询事件
*/
function handleSuperQuery(params) {
Object.keys(params).map((k) => {
queryParam[k] = params[k];
});
reload();
}
/**
* 新增事件
*/
function handleAdd() {
openModal(true, {
isUpdate: false,
showFooter: true,
});
}
/**
* 编辑事件
*/
function handleEdit(record: Recordable) {
openModal(true, {
record,
isUpdate: true,
showFooter: true,
});
}
/**
* 详情
*/
function handleDetail(record: Recordable) {
openModal(true, {
record,
isUpdate: true,
showFooter: false,
});
}
/**
* 删除事件
*/
async function handleDelete(record) {
await deleteOne({id: record.id}, handleSuccess);
}
/**
* 批量删除事件
*/
async function batchHandleDelete() {
await batchDelete({ids: selectedRowKeys.value}, handleSuccess);
}
/**
* 成功回调
*/
function handleSuccess() {
(selectedRowKeys.value = []) && reload();
}
/**
* 操作栏
*/
function getTableAction(record){
return [
{
label: '编辑',
onClick: handleEdit.bind(null, record),
auth: 'appletArticle:applet_article:edit'
}
]
}
/**
* 下拉操作栏
*/
function getDropDownAction(record){
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
}, {
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
placement: 'topLeft',
},
auth: 'appletArticle:applet_article:delete'
}
]
}
</script>
<style lang="less" scoped>
:deep(.ant-picker),:deep(.ant-input-number){
width: 100%;
}
</style>

+ 26
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/vue3/V20251023_1__menu_insert_AppletArticle.sql View File

@ -0,0 +1,26 @@
-- 注意:该页面对应的前台目录为views/appletArticle文件夹下
-- 如果你想更改到其他目录,请修改sql中component字段对应的值
INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_route, is_leaf, keep_alive, hidden, hide_tab, description, status, del_flag, rule_flag, create_by, create_time, update_by, update_time, internal_or_external)
VALUES ('2025102304348630020', NULL, '小程序文章', '/appletArticle/appletArticleList', 'appletArticle/AppletArticleList', NULL, NULL, 0, NULL, '1', 0.00, 0, NULL, 1, 0, 0, 0, 0, NULL, '1', 0, 0, 'admin', '2025-10-23 16:34:02', NULL, NULL, 0);
-- 权限控制sql
-- 新增
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2025102304348630021', '2025102304348630020', '添加小程序文章', NULL, NULL, 0, NULL, NULL, 2, 'appletArticle:applet_article:add', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-10-23 16:34:02', NULL, NULL, 0, 0, '1', 0);
-- 编辑
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2025102304348630022', '2025102304348630020', '编辑小程序文章', NULL, NULL, 0, NULL, NULL, 2, 'appletArticle:applet_article:edit', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-10-23 16:34:02', NULL, NULL, 0, 0, '1', 0);
-- 删除
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2025102304348630023', '2025102304348630020', '删除小程序文章', NULL, NULL, 0, NULL, NULL, 2, 'appletArticle:applet_article:delete', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-10-23 16:34:02', NULL, NULL, 0, 0, '1', 0);
-- 批量删除
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2025102304348630024', '2025102304348630020', '批量删除小程序文章', NULL, NULL, 0, NULL, NULL, 2, 'appletArticle:applet_article:deleteBatch', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-10-23 16:34:02', NULL, NULL, 0, 0, '1', 0);
-- 导出excel
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2025102304348630025', '2025102304348630020', '导出excel_小程序文章', NULL, NULL, 0, NULL, NULL, 2, 'appletArticle:applet_article:exportXls', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-10-23 16:34:02', NULL, NULL, 0, 0, '1', 0);
-- 导入excel
INSERT INTO sys_permission(id, parent_id, name, url, component, is_route, component_name, redirect, menu_type, perms, perms_type, sort_no, always_show, icon, is_leaf, keep_alive, hidden, hide_tab, description, create_by, create_time, update_by, update_time, del_flag, rule_flag, status, internal_or_external)
VALUES ('2025102304348630026', '2025102304348630020', '导入excel_小程序文章', NULL, NULL, 0, NULL, NULL, 2, 'appletArticle:applet_article:importExcel', '1', NULL, 0, NULL, 1, 0, 0, 0, NULL, 'admin', '2025-10-23 16:34:02', NULL, NULL, 0, 0, '1', 0);

+ 70
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/vue3/components/AppletArticleForm.vue View File

@ -0,0 +1,70 @@
<template>
<div style="min-height: 400px">
<BasicForm @register="registerForm"></BasicForm>
<div style="width: 100%;text-align: center" v-if="!formDisabled">
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary"> </a-button>
</div>
</div>
</template>
<script lang="ts">
import {BasicForm, useForm} from '/@/components/Form/index';
import {computed, defineComponent} from 'vue';
import {defHttp} from '/@/utils/http/axios';
import { propTypes } from '/@/utils/propTypes';
import {getBpmFormSchema} from '../AppletArticle.data';
import {saveOrUpdate} from '../AppletArticle.api';
export default defineComponent({
name: "AppletArticleForm",
components:{
BasicForm
},
props:{
formData: propTypes.object.def({}),
formBpm: propTypes.bool.def(true),
},
setup(props){
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
labelWidth: 150,
schemas: getBpmFormSchema(props.formData),
showActionButtonGroup: false,
baseColProps: {span: 24}
});
const formDisabled = computed(()=>{
if(props.formData.disabled === false){
return false;
}
return true;
});
let formData = {};
const queryByIdUrl = '/appletArticle/appletArticle/queryById';
async function initFormData(){
let params = {id: props.formData.dataId};
const data = await defHttp.get({url: queryByIdUrl, params});
formData = {...data}
//
await setFieldsValue(formData);
//
await setProps({disabled: formDisabled.value})
}
async function submitForm() {
let data = getFieldsValue();
let params = Object.assign({}, formData, data);
console.log('表单数据', params)
await saveOrUpdate(params, true)
}
initFormData();
return {
registerForm,
formDisabled,
submitForm,
}
}
});
</script>

+ 99
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletArticle/vue3/components/AppletArticleModal.vue View File

@ -0,0 +1,99 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
<BasicForm @register="registerForm" name="AppletArticleForm" />
</BasicModal>
</template>
<script lang="ts" setup>
import {ref, computed, unref, reactive} from 'vue';
import {BasicModal, useModalInner} from '/@/components/Modal';
import {BasicForm, useForm} from '/@/components/Form/index';
import {formSchema} from '../AppletArticle.data';
import {saveOrUpdate} from '../AppletArticle.api';
import { useMessage } from '/@/hooks/web/useMessage';
import { getDateByPicker } from '/@/utils';
const { createMessage } = useMessage();
// Emits
const emit = defineEmits(['register','success']);
const isUpdate = ref(true);
const isDetail = ref(false);
//
const [registerForm, { setProps,resetFields, setFieldsValue, validate, scrollToField }] = useForm({
labelWidth: 150,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: {span: 24}
});
//
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
//
await resetFields();
setModalProps({confirmLoading: false,showCancelBtn:!!data?.showFooter,showOkBtn:!!data?.showFooter});
isUpdate.value = !!data?.isUpdate;
isDetail.value = !!data?.showFooter;
if (unref(isUpdate)) {
//
await setFieldsValue({
...data.record,
});
}
//
setProps({ disabled: !data?.showFooter })
});
//
const fieldPickers = reactive({
});
//
const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(isDetail) ? '详情' : '编辑'));
//
async function handleSubmit(v) {
try {
let values = await validate();
//
changeDateValue(values);
setModalProps({confirmLoading: true});
//
await saveOrUpdate(values, isUpdate.value);
//
closeModal();
//
emit('success');
} catch ({ errorFields }) {
if (errorFields) {
const firstField = errorFields[0];
if (firstField) {
scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
}
}
return Promise.reject(errorFields);
} finally {
setModalProps({confirmLoading: false});
}
}
/**
* 处理日期值
* @param formData 表单数据
*/
const changeDateValue = (formData) => {
if (formData && fieldPickers) {
for (let key in fieldPickers) {
if (formData[key]) {
formData[key] = getDateByPicker(formData[key], fieldPickers[key]);
}
}
}
};
</script>
<style lang="less" scoped>
/** 时间和数字输入框样式 */
:deep(.ant-input-number) {
width: 100%;
}
:deep(.ant-calendar-picker) {
width: 100%;
}
</style>

+ 1
- 1
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletTtsCache/entity/AppletTtsCache.java View File

@ -99,5 +99,5 @@ public class AppletTtsCache implements Serializable {
private java.lang.Integer state; private java.lang.Integer state;
@Schema(description = "时间戳") @Schema(description = "时间戳")
private java.lang.String timestamps;
private java.lang.String subtitlesJson;
} }

+ 64
- 0
jeecgboot-vue3/src/views/applet/article/AppletArticle.api.ts View File

@ -0,0 +1,64 @@
import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";
const { createConfirm } = useMessage();
enum Api {
list = '/appletArticle/appletArticle/list',
save='/appletArticle/appletArticle/add',
edit='/appletArticle/appletArticle/edit',
deleteOne = '/appletArticle/appletArticle/delete',
deleteBatch = '/appletArticle/appletArticle/deleteBatch',
importExcel = '/appletArticle/appletArticle/importExcel',
exportXls = '/appletArticle/appletArticle/exportXls',
}
/**
* api
* @param params
*/
export const getExportUrl = Api.exportXls;
/**
* api
*/
export const getImportUrl = Api.importExcel;
/**
*
* @param params
*/
export const list = (params) =>
defHttp.get({url: Api.list, params});
/**
*
*/
export const deleteOne = (params,handleSuccess) => {
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
/**
*
* @param params
*/
export const batchDelete = (params, handleSuccess) => {
createConfirm({
iconType: 'warning',
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
});
}
/**
*
* @param params
*/
export const saveOrUpdate = (params, isUpdate) => {
let url = isUpdate ? Api.edit : Api.save;
return defHttp.post({url: url, params});
}

+ 77
- 0
jeecgboot-vue3/src/views/applet/article/AppletArticle.data.ts View File

@ -0,0 +1,77 @@
import {BasicColumn} from '/src/components/Table';
import {FormSchema} from '/src/components/Table';
import { rules} from '/src/utils/helper/validator';
import { render } from '/src/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/src/utils';
//列表数据
export const columns: BasicColumn[] = [
{
title: '标题',
align:"center",
dataIndex: 'title'
},
{
title: '排序',
align:"center",
dataIndex: 'sort'
},
{
title: '上架',
align:"center",
dataIndex: 'status',
customRender:({text}) => {
return render.renderSwitch(text, [{text:'是',value:'Y'},{text:'否',value:'N'}])
},
},
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
{
label: '标题',
field: 'title',
component: 'Input',
},
{
label: '排序',
field: 'sort',
component: 'InputNumber',
},
{
label: '上架',
field: 'status',
component: 'JSwitch',
componentProps:{
},
},
{
label: '内容',
field: 'content',
component: 'JEditor',
},
// TODO 主键隐藏字段,目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false
},
];
// 高级查询数据
export const superQuerySchema = {
title: {title: '标题',order: 0,view: 'text', type: 'string',},
sort: {title: '排序',order: 1,view: 'number', type: 'number',},
status: {title: '上架',order: 2,view: 'switch', type: 'string',},
};
/**
* formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
// 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
return formSchema;
}

+ 206
- 0
jeecgboot-vue3/src/views/applet/article/AppletArticleList.vue View File

@ -0,0 +1,206 @@
<template>
<div>
<!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" v-auth="'appletArticle:applet_article:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" v-auth="'appletArticle:applet_article:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" v-auth="'appletArticle:applet_article:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon>
删除
</a-menu-item>
</a-menu>
</template>
<a-button v-auth="'appletArticle:applet_article:deleteBatch'">批量操作
<Icon icon="mdi:chevron-down"></Icon>
</a-button>
</a-dropdown>
<!-- 高级查询 -->
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
</template>
<!--字段回显插槽-->
<template v-slot:bodyCell="{ column, record, index, text }">
</template>
</BasicTable>
<!-- 表单区域 -->
<AppletArticleModal @register="registerModal" @success="handleSuccess"></AppletArticleModal>
</div>
</template>
<script lang="ts" name="appletArticle-appletArticle" setup>
import {ref, reactive, computed, unref} from 'vue';
import {BasicTable, useTable, TableAction} from '/@/components/Table';
import {useModal} from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage'
import AppletArticleModal from './components/AppletArticleModal.vue'
import {columns, searchFormSchema, superQuerySchema} from './AppletArticle.data';
import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './AppletArticle.api';
import { downloadFile } from '/@/utils/common/renderUtils';
import { useUserStore } from '/@/store/modules/user';
import { useMessage } from '/@/hooks/web/useMessage';
import { getDateByPicker } from '/@/utils';
//
const fieldPickers = reactive({
});
const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]);
const userStore = useUserStore();
const { createMessage } = useMessage();
//model
const [registerModal, {openModal}] = useModal();
//table
const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
tableProps:{
title: '小程序文章',
api: list,
columns,
canResize:true,
formConfig: {
//labelWidth: 120,
schemas: searchFormSchema,
autoSubmitOnEnter:true,
showAdvancedButton:true,
fieldMapToNumber: [
],
fieldMapToTime: [
],
},
actionColumn: {
width: 120,
fixed:'right'
},
beforeFetch: (params) => {
if (params && fieldPickers) {
for (let key in fieldPickers) {
if (params[key]) {
params[key] = getDateByPicker(params[key], fieldPickers[key]);
}
}
}
return Object.assign(params, queryParam);
},
},
exportConfig: {
name:"小程序文章",
url: getExportUrl,
params: queryParam,
},
importConfig: {
url: getImportUrl,
success: handleSuccess
},
})
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
//
const superQueryConfig = reactive(superQuerySchema);
/**
* 高级查询事件
*/
function handleSuperQuery(params) {
Object.keys(params).map((k) => {
queryParam[k] = params[k];
});
reload();
}
/**
* 新增事件
*/
function handleAdd() {
openModal(true, {
isUpdate: false,
showFooter: true,
});
}
/**
* 编辑事件
*/
function handleEdit(record: Recordable) {
openModal(true, {
record,
isUpdate: true,
showFooter: true,
});
}
/**
* 详情
*/
function handleDetail(record: Recordable) {
openModal(true, {
record,
isUpdate: true,
showFooter: false,
});
}
/**
* 删除事件
*/
async function handleDelete(record) {
await deleteOne({id: record.id}, handleSuccess);
}
/**
* 批量删除事件
*/
async function batchHandleDelete() {
await batchDelete({ids: selectedRowKeys.value}, handleSuccess);
}
/**
* 成功回调
*/
function handleSuccess() {
(selectedRowKeys.value = []) && reload();
}
/**
* 操作栏
*/
function getTableAction(record){
return [
{
label: '编辑',
onClick: handleEdit.bind(null, record),
auth: 'appletArticle:applet_article:edit'
}
]
}
/**
* 下拉操作栏
*/
function getDropDownAction(record){
return [
{
label: '详情',
onClick: handleDetail.bind(null, record),
}, {
label: '删除',
popConfirm: {
title: '是否确认删除',
confirm: handleDelete.bind(null, record),
placement: 'topLeft',
},
auth: 'appletArticle:applet_article:delete'
}
]
}
</script>
<style lang="less" scoped>
:deep(.ant-picker),:deep(.ant-input-number){
width: 100%;
}
</style>

+ 70
- 0
jeecgboot-vue3/src/views/applet/article/components/AppletArticleForm.vue View File

@ -0,0 +1,70 @@
<template>
<div style="min-height: 400px">
<BasicForm @register="registerForm"></BasicForm>
<div style="width: 100%;text-align: center" v-if="!formDisabled">
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary"> </a-button>
</div>
</div>
</template>
<script lang="ts">
import {BasicForm, useForm} from '/@/components/Form/index';
import {computed, defineComponent} from 'vue';
import {defHttp} from '/@/utils/http/axios';
import { propTypes } from '/@/utils/propTypes';
import {getBpmFormSchema} from '../AppletArticle.data';
import {saveOrUpdate} from '../AppletArticle.api';
export default defineComponent({
name: "AppletArticleForm",
components:{
BasicForm
},
props:{
formData: propTypes.object.def({}),
formBpm: propTypes.bool.def(true),
},
setup(props){
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
labelWidth: 150,
schemas: getBpmFormSchema(props.formData),
showActionButtonGroup: false,
baseColProps: {span: 24}
});
const formDisabled = computed(()=>{
if(props.formData.disabled === false){
return false;
}
return true;
});
let formData = {};
const queryByIdUrl = '/appletArticle/appletArticle/queryById';
async function initFormData(){
let params = {id: props.formData.dataId};
const data = await defHttp.get({url: queryByIdUrl, params});
formData = {...data}
//
await setFieldsValue(formData);
//
await setProps({disabled: formDisabled.value})
}
async function submitForm() {
let data = getFieldsValue();
let params = Object.assign({}, formData, data);
console.log('表单数据', params)
await saveOrUpdate(params, true)
}
initFormData();
return {
registerForm,
formDisabled,
submitForm,
}
}
});
</script>

+ 99
- 0
jeecgboot-vue3/src/views/applet/article/components/AppletArticleModal.vue View File

@ -0,0 +1,99 @@
<template>
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
<BasicForm @register="registerForm" name="AppletArticleForm" />
</BasicModal>
</template>
<script lang="ts" setup>
import {ref, computed, unref, reactive} from 'vue';
import {BasicModal, useModalInner} from '/@/components/Modal';
import {BasicForm, useForm} from '/@/components/Form/index';
import {formSchema} from '../AppletArticle.data';
import {saveOrUpdate} from '../AppletArticle.api';
import { useMessage } from '/@/hooks/web/useMessage';
import { getDateByPicker } from '/@/utils';
const { createMessage } = useMessage();
// Emits
const emit = defineEmits(['register','success']);
const isUpdate = ref(true);
const isDetail = ref(false);
//
const [registerForm, { setProps,resetFields, setFieldsValue, validate, scrollToField }] = useForm({
labelWidth: 150,
schemas: formSchema,
showActionButtonGroup: false,
baseColProps: {span: 24}
});
//
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
//
await resetFields();
setModalProps({confirmLoading: false,showCancelBtn:!!data?.showFooter,showOkBtn:!!data?.showFooter});
isUpdate.value = !!data?.isUpdate;
isDetail.value = !!data?.showFooter;
if (unref(isUpdate)) {
//
await setFieldsValue({
...data.record,
});
}
//
setProps({ disabled: !data?.showFooter })
});
//
const fieldPickers = reactive({
});
//
const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(isDetail) ? '详情' : '编辑'));
//
async function handleSubmit(v) {
try {
let values = await validate();
//
changeDateValue(values);
setModalProps({confirmLoading: true});
//
await saveOrUpdate(values, isUpdate.value);
//
closeModal();
//
emit('success');
} catch ({ errorFields }) {
if (errorFields) {
const firstField = errorFields[0];
if (firstField) {
scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
}
}
return Promise.reject(errorFields);
} finally {
setModalProps({confirmLoading: false});
}
}
/**
* 处理日期值
* @param formData 表单数据
*/
const changeDateValue = (formData) => {
if (formData && fieldPickers) {
for (let key in fieldPickers) {
if (formData[key]) {
formData[key] = getDateByPicker(formData[key], fieldPickers[key]);
}
}
}
};
</script>
<style lang="less" scoped>
/** 时间和数字输入框样式 */
:deep(.ant-input-number) {
width: 100%;
}
:deep(.ant-calendar-picker) {
width: 100%;
}
</style>

Loading…
Cancel
Save