mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-03-20 16:13:44 +08:00
init v1.0.0
This commit is contained in:
@@ -94,7 +94,7 @@ public class CaptchaController {
|
||||
String code = RandomUtil.randomNumbers(4);
|
||||
RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
|
||||
try {
|
||||
MailUtils.sendText(emailRequest.getUsername(), "【GPT助手】登录验证码", "您本次验证码为:" + code + ",有效性为" + Constants.CAPTCHA_EXPIRATION + "分钟,请尽快填写。");
|
||||
MailUtils.sendText(emailRequest.getUsername(), "【熊猫助手】登录验证码", "您本次验证码为:" + code + ",有效性为" + Constants.CAPTCHA_EXPIRATION + "分钟,请尽快填写。");
|
||||
} catch (Exception e) {
|
||||
log.error("验证码短信发送异常 => {}", e.getMessage());
|
||||
return R.fail(e.getMessage());
|
||||
|
||||
@@ -3,7 +3,10 @@ package com.xmzs.controller;
|
||||
|
||||
import com.xmzs.common.chat.domain.request.ChatRequest;
|
||||
import com.xmzs.common.chat.domain.request.Dall3Request;
|
||||
import com.xmzs.common.chat.domain.request.MjTaskRequest;
|
||||
import com.xmzs.common.chat.entity.Tts.TextToSpeech;
|
||||
import com.xmzs.common.chat.entity.images.Item;
|
||||
import com.xmzs.common.chat.entity.whisper.WhisperResponse;
|
||||
import com.xmzs.common.core.domain.R;
|
||||
import com.xmzs.common.core.domain.model.LoginUser;
|
||||
import com.xmzs.common.core.exception.base.BaseException;
|
||||
@@ -13,19 +16,30 @@ import com.xmzs.common.satoken.utils.LoginHelper;
|
||||
import com.xmzs.system.domain.bo.ChatMessageBo;
|
||||
import com.xmzs.system.domain.vo.ChatMessageVo;
|
||||
import com.xmzs.system.service.IChatMessageService;
|
||||
import com.xmzs.system.service.SseService;
|
||||
import com.xmzs.system.service.ISseService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import retrofit2.Response;
|
||||
|
||||
/**
|
||||
* 描述:
|
||||
*
|
||||
@@ -37,38 +51,58 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class ChatController {
|
||||
|
||||
private final SseService sseService;
|
||||
private final ISseService ISseService;
|
||||
|
||||
private final IChatMessageService chatMessageService;
|
||||
private final IChatMessageService chatMessageService;
|
||||
|
||||
/**
|
||||
* 聊天接口
|
||||
*/
|
||||
@PostMapping("/chat")
|
||||
@ResponseBody
|
||||
public SseEmitter sseChat(@RequestBody @Valid ChatRequest chatRequest) {
|
||||
if("gpt-4-all".equals(chatRequest.getModel())
|
||||
|| chatRequest.getModel().startsWith("gpt-4-gizmo")
|
||||
|| chatRequest.getModel().startsWith("net-")
|
||||
){
|
||||
return sseService.transitChat(chatRequest);
|
||||
}
|
||||
if("azure-gpt-3.5".equals(chatRequest.getModel())){
|
||||
return sseService.azureChat(chatRequest);
|
||||
}
|
||||
return sseService.sseChat(chatRequest);
|
||||
public SseEmitter sseChat(@RequestBody @Valid ChatRequest chatRequest, HttpServletResponse response) {
|
||||
return ISseService.sseChat(chatRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 语音转文本
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
@PostMapping("/audio")
|
||||
@ResponseBody
|
||||
public WhisperResponse audio(@RequestParam("file") MultipartFile file) {
|
||||
WhisperResponse whisperResponse = ISseService.speechToTextTranscriptionsV2(file);
|
||||
return whisperResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文本转语音
|
||||
*
|
||||
* @param textToSpeech
|
||||
*/
|
||||
@PostMapping("/speech")
|
||||
@ResponseBody
|
||||
public ResponseEntity<Resource> speech(@RequestBody TextToSpeech textToSpeech) {
|
||||
return ISseService.textToSpeed(textToSpeech);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/dall3")
|
||||
@ResponseBody
|
||||
public R<List<Item>> dall3(@RequestBody @Valid Dall3Request request) {
|
||||
return R.ok(sseService.dall3(request));
|
||||
return R.ok(ISseService.dall3(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 扣除mj绘图费用
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/mjTask")
|
||||
@ResponseBody
|
||||
public R<String> mjTask() {
|
||||
sseService.mjTask();
|
||||
public R<String> mjTask(@RequestBody MjTaskRequest mjTaskRequest) {
|
||||
ISseService.mjTask(mjTaskRequest);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@@ -77,7 +111,7 @@ public class ChatController {
|
||||
*/
|
||||
@PostMapping("/chatList")
|
||||
@ResponseBody
|
||||
public R<TableDataInfo<ChatMessageVo>> list(@RequestBody @Valid ChatMessageBo chatRequest,@RequestBody PageQuery pageQuery) {
|
||||
public R<TableDataInfo<ChatMessageVo>> list(@RequestBody @Valid ChatMessageBo chatRequest, @RequestBody PageQuery pageQuery) {
|
||||
// 默认查询当前登录用户消息记录
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
if (loginUser == null) {
|
||||
|
||||
@@ -73,7 +73,6 @@ public class PayController {
|
||||
return R.ok(paymentOrdersVo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 跳转通知地址
|
||||
*
|
||||
@@ -138,6 +137,9 @@ public class PayController {
|
||||
BeanUtil.copyProperties(paymentOrdersVo,paymentOrdersBo);
|
||||
paymentOrdersService.updateByBo(paymentOrdersBo);
|
||||
SysUserVo sysUserVo = userService.selectUserById(paymentOrdersVo.getUserId());
|
||||
if(money>9.9){
|
||||
money = money*2;
|
||||
}
|
||||
sysUserVo.setUserBalance(sysUserVo.getUserBalance()+money);
|
||||
SysUserBo sysUserBo = new SysUserBo();
|
||||
BeanUtil.copyProperties(sysUserVo,sysUserBo);
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.xmzs.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.xmzs.common.wechat.Wechat;
|
||||
import com.xmzs.system.cofing.KeywordConfig;
|
||||
import com.xmzs.system.cofing.QqConfig;
|
||||
import com.xmzs.system.cofing.WechatConfig;
|
||||
import com.xmzs.system.handler.WechatMessageHandler;
|
||||
import com.xmzs.system.service.ISseService;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 个人微信扩展控制器
|
||||
*
|
||||
* @author WangLe
|
||||
*/
|
||||
@SaIgnore
|
||||
@Slf4j
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
public class WeChatController {
|
||||
|
||||
@Getter
|
||||
private Wechat wechatBot;
|
||||
|
||||
private final WechatConfig wechatConfig;
|
||||
|
||||
private final ISseService sseService;
|
||||
|
||||
private final KeywordConfig keywordConfig;
|
||||
|
||||
/**
|
||||
* 获取微信登录二维码
|
||||
*
|
||||
*/
|
||||
@PostMapping("/getQr")
|
||||
public void getQr() {
|
||||
//微信
|
||||
if (wechatConfig.getEnable()){
|
||||
log.info("正在登录微信,请按提示操作:");
|
||||
wechatBot = new Wechat(new WechatMessageHandler(sseService, keywordConfig), wechatConfig.getQrPath());
|
||||
wechatBot.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user