mirror of
https://github.com/201206030/novel-plus.git
synced 2025-04-26 09:20:50 +00:00
fix: 小说封面图修改
This commit is contained in:
parent
0e156c04b4
commit
3f009dc1f9
@ -69,4 +69,8 @@ public interface CacheKey {
|
||||
* 测试爬虫规则缓存
|
||||
*/
|
||||
String BOOK_TEST_PARSE = "testParse";
|
||||
/**
|
||||
* AI生成图片
|
||||
* */
|
||||
String AI_GEN_PIC = "aiGenPic";
|
||||
}
|
||||
|
@ -238,6 +238,14 @@ public class AuthorController extends BaseController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询AI生成图片
|
||||
*/
|
||||
@GetMapping("queryAiGenPic")
|
||||
public RestResult<String> queryAiGenPic(@RequestParam("bookId") Long bookId) {
|
||||
return RestResult.ok(bookService.queryAiGenPic(bookId));
|
||||
}
|
||||
|
||||
/**
|
||||
* AI扩写
|
||||
*/
|
||||
|
@ -290,4 +290,9 @@ public interface BookService {
|
||||
* @param authorId
|
||||
*/
|
||||
void updateBookPic(Long bookId, String bookPic, Long authorId);
|
||||
|
||||
/**
|
||||
* 查询AI生成图片
|
||||
*/
|
||||
String queryAiGenPic(Long bookId);
|
||||
}
|
||||
|
@ -559,6 +559,7 @@ public class BookServiceImpl implements BookService {
|
||||
.where(id, isEqualTo(book.getId()))
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3));
|
||||
cacheService.set(CacheKey.AI_GEN_PIC + book.getId(), picUrl, 60 * 60);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -882,5 +883,10 @@ public class BookServiceImpl implements BookService {
|
||||
.render(RenderingStrategies.MYBATIS3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String queryAiGenPic(Long bookId) {
|
||||
return cacheService.get(CacheKey.AI_GEN_PIC + bookId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -51,8 +51,7 @@
|
||||
</div>
|
||||
<div class="my_r">
|
||||
<div id="noContentDiv">
|
||||
<div class="tc" style="margin-top: 200px"><a href="/author/book_add.html" class="btn_red">创建作品</a>
|
||||
</div>
|
||||
<div class="tc" style="margin-top: 200px"><a href="/author/book_add.html" class="btn_red">创建作品</a></div>
|
||||
|
||||
</div>
|
||||
<div class="my_bookshelf" id="hasContentDiv" style="display: none">
|
||||
@ -143,13 +142,12 @@
|
||||
<script src="/javascript/common.js" type="text/javascript"></script>
|
||||
|
||||
<script language="javascript" type="text/javascript">
|
||||
var searchCount = 0;
|
||||
var timeout;
|
||||
var coverUpdateInterval;
|
||||
|
||||
search(1, 5);
|
||||
|
||||
function search(curr, limit) {
|
||||
searchCount++;
|
||||
clearTimeout(timeout);
|
||||
clearInterval(coverUpdateInterval);
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "/author/listBookByPage",
|
||||
@ -159,7 +157,25 @@
|
||||
if (data.code == 200) {
|
||||
var bookList = data.data.list;
|
||||
if (bookList.length > 0) {
|
||||
var aiPicGenerating = bookList[0].picUrl == '/images/default.gif'
|
||||
if(curr == 1 && bookList[0].picUrl == '/images/default.gif'){
|
||||
coverUpdateInterval = setInterval(function(){
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "/author/queryAiGenPic",
|
||||
data: {'bookId': bookList[0].id},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if(data.code == 200 && data.data){
|
||||
$("#cover"+bookList[0].id).attr("src", data.data);
|
||||
clearInterval(coverUpdateInterval);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 3000);
|
||||
setTimeout(() => {
|
||||
clearInterval(coverUpdateInterval);
|
||||
}, 10000);
|
||||
}
|
||||
$("#hasContentDiv").css("display", "block");
|
||||
$("#noContentDiv").css("display", "none");
|
||||
var bookListHtml = "";
|
||||
@ -171,15 +187,12 @@
|
||||
" </td>\n" +*/
|
||||
|
||||
" <td style=\"position: relative\" class=\"goread\">\n" +
|
||||
"<input class=\"opacity\" onchange=\"picChange('" + book.id + "'," + i + ")\"\n" +
|
||||
" type=\"file\" id=\"file" + i + "\" name=\"file\"\n" +
|
||||
"<input class=\"opacity\" onchange=\"picChange('" + book.id + "')\"\n" +
|
||||
" type=\"file\" id=\"file" + book.id + "\" name=\"file\"\n" +
|
||||
" title=\"点击上传图片\"\n" +
|
||||
" style=\"z-index: 100;cursor: pointer;left: 30px; top: 0px; width: 60px; height: 80px; opacity: 0; position: absolute; \"\n" +
|
||||
" />" +
|
||||
"<img width='50' height='70' src='" + book.picUrl + "'/><br/>" +
|
||||
" " + book.bookName + "</td>\n" +
|
||||
|
||||
|
||||
"<img id=\"cover" + book.id + "\" width='50' height='70' src='" + book.picUrl + "'/><br/>" + " " + book.bookName + "</td>\n" +
|
||||
" <td class=\"goread\" >"
|
||||
+ book.catName + "</td>\n" +
|
||||
|
||||
@ -231,12 +244,6 @@
|
||||
});
|
||||
});
|
||||
|
||||
if (curr === 1 && aiPicGenerating && searchCount < 10) {
|
||||
timeout = setTimeout(function () {
|
||||
search(curr, limit);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -288,19 +295,20 @@
|
||||
}
|
||||
|
||||
|
||||
function picChange(bookId, i) {
|
||||
var file = $("#file" + i).val(); //文件名称
|
||||
function picChange(bookId) {
|
||||
var file = $("#file" + bookId).val(); //文件名称
|
||||
if (file != "") {
|
||||
if (checkPicUpload($("#file" + i)[0])) {
|
||||
if (checkPicUpload($("#file" + bookId)[0])) {
|
||||
|
||||
$.ajaxFileUpload({
|
||||
url: "/file/picUpload", //用于文件上传的服务器端请求地址
|
||||
secureuri: false, //是否需要安全协议,一般设置为false
|
||||
fileElementId: "file" + i, //文件上传域的ID
|
||||
fileElementId: "file" + bookId, //文件上传域的ID
|
||||
dataType: "json", //返回值类型 一般设置为json
|
||||
type: "post",
|
||||
success: function (data) { //服务器成功响应处理函数
|
||||
if (data.code == 200) {
|
||||
let picUrl = data.data;
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/author/updateBookPic",
|
||||
@ -308,17 +316,13 @@
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
|
||||
location.reload();
|
||||
|
||||
$("#cover"+bookId).attr("src", picUrl);
|
||||
} else {
|
||||
lock = false;
|
||||
layer.alert(data.msg);
|
||||
}
|
||||
|
||||
},
|
||||
error: function () {
|
||||
lock = false;
|
||||
layer.alert('网络异常');
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user