mirror of
https://github.com/Geniusay/ChopperBot.git
synced 2026-09-03 06:25:04 +08:00
GPT Key API和web接口
This commit is contained in:
4
.idea/compiler.xml
generated
4
.idea/compiler.xml
generated
@@ -38,7 +38,7 @@
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||
<module name="ChopperBot" options="-parameters" />
|
||||
<module name="ChopperBot" options="" />
|
||||
<module name="chopperbot-account" options="-parameters" />
|
||||
<module name="chopperbot-barrage" options="-parameters" />
|
||||
<module name="chopperbot-common" options="-parameters" />
|
||||
@@ -53,4 +53,4 @@
|
||||
<module name="chopperbot-test" options="-parameters" />
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
</project>
|
||||
@@ -36,7 +36,10 @@ public class GPTApi {
|
||||
}
|
||||
|
||||
public boolean addKey(GPTKey key){
|
||||
return mapper.insert(key)==1;
|
||||
if (mapper.selectCount(new QueryWrapper<GPTKey>())==0) {
|
||||
return mapper.insert(key)==1;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public GPTKey getKey(){
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
package org.example.controller;
|
||||
|
||||
|
||||
import org.apache.tools.ant.taskdefs.Get;
|
||||
import org.example.core.pojo.Account;
|
||||
import org.example.core.pojo.AccountVO;
|
||||
import org.example.pojo.GPTKey;
|
||||
import org.example.service.AccountService;
|
||||
import org.example.util.Result;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
@@ -44,4 +47,21 @@ public class AccountController {
|
||||
accountService.edit(account);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@GetMapping(value = "/gpt/key")
|
||||
public Result getGPT(){
|
||||
return Result.success(Map.of("key",accountService.chatGptPlugin().getKey()));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/gpt/add")
|
||||
public Result addGPT(@RequestBody GPTKey key){
|
||||
boolean b = accountService.chatGptPlugin().addKey(key);
|
||||
return Result.success(Map.of("success",b));
|
||||
}
|
||||
|
||||
@PostMapping(value="/gpt/update")
|
||||
public Result updateGPT(@RequestBody GPTKey key){
|
||||
boolean b = accountService.chatGptPlugin().changeKey(key);
|
||||
return Result.success(Map.of("success",b));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user