mirror of
https://github.com/201206030/novel-plus.git
synced 2025-08-20 06:58:44 +00:00
Compare commits
7 Commits
v5.2.3
...
develop_xx
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0564871093 | ||
![]() |
d6faab8ca1 | ||
![]() |
1ef64edcda | ||
![]() |
c24c68ecaf | ||
![]() |
7e27456a65 | ||
![]() |
d4e8fb1cc7 | ||
![]() |
d4e1126873 |
@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.java2nb</groupId>
|
||||
<artifactId>novel-admin</artifactId>
|
||||
<version>5.2.3</version>
|
||||
<version>5.2.5</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>novel-admin</name>
|
||||
|
@ -9,7 +9,7 @@ import com.java2nb.novel.service.FriendLinkService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -31,7 +31,7 @@ public class FriendLinkController {
|
||||
@Autowired
|
||||
private FriendLinkService friendLinkService;
|
||||
@Autowired
|
||||
private RedisTemplate<Object, Object> redisTemplate;
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@GetMapping()
|
||||
@RequiresPermissions("novel:friendLink:friendLink")
|
||||
|
@ -9,7 +9,7 @@ import com.java2nb.novel.service.NewsService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -32,7 +32,7 @@ public class NewsController {
|
||||
@Autowired
|
||||
private NewsService newsService;
|
||||
@Autowired
|
||||
private RedisTemplate<Object, Object> redisTemplate;
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@GetMapping()
|
||||
@RequiresPermissions("novel:news:news")
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>novel</artifactId>
|
||||
<groupId>com.java2nb</groupId>
|
||||
<version>5.2.3</version>
|
||||
<version>5.2.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -8,7 +8,7 @@ public interface CacheKey {
|
||||
/**
|
||||
* 首页小说设置
|
||||
* */
|
||||
String INDEX_BOOK_SETTINGS_KEY = "indexBookSettingsKey";
|
||||
String INDEX_BOOK_SETTINGS_KEY = "indexBookSettingsKey:v2";
|
||||
|
||||
/**
|
||||
* 首页新闻
|
||||
|
@ -1,55 +1,61 @@
|
||||
package com.java2nb.novel.core.cache;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 11797
|
||||
*/
|
||||
public interface CacheService {
|
||||
|
||||
/**
|
||||
* 根据key获取缓存的String类型数据
|
||||
*/
|
||||
String get(String key);
|
||||
/**
|
||||
* 根据key获取缓存的String类型数据
|
||||
*/
|
||||
String get(String key);
|
||||
|
||||
/**
|
||||
* 设置String类型的缓存
|
||||
*/
|
||||
void set(String key, String value);
|
||||
/**
|
||||
* 设置String类型的缓存
|
||||
*/
|
||||
void set(String key, String value);
|
||||
|
||||
/**
|
||||
* 设置一个有过期时间的String类型的缓存,单位秒
|
||||
*/
|
||||
void set(String key, String value, long timeout);
|
||||
|
||||
/**
|
||||
* 根据key获取缓存的Object类型数据
|
||||
*/
|
||||
Object getObject(String key);
|
||||
|
||||
/**
|
||||
* 设置Object类型的缓存
|
||||
*/
|
||||
void setObject(String key, Object value);
|
||||
|
||||
/**
|
||||
* 设置一个有过期时间的Object类型的缓存,单位秒
|
||||
*/
|
||||
/**
|
||||
* 设置一个有过期时间的String类型的缓存,单位秒
|
||||
*/
|
||||
void set(String key, String value, long timeout);
|
||||
|
||||
/**
|
||||
* 根据key获取缓存的Object类型数据
|
||||
*/
|
||||
<T> T getObject(String key, Class<T> clazz);
|
||||
|
||||
<T> List<T> getList(String key, Class<T> clazz);
|
||||
|
||||
/**
|
||||
* 设置Object类型的缓存
|
||||
*/
|
||||
void setObject(String key, Object value);
|
||||
|
||||
/**
|
||||
* 设置一个有过期时间的Object类型的缓存,单位秒
|
||||
*/
|
||||
void setObject(String key, Object value, long timeout);
|
||||
|
||||
/**
|
||||
* 根据key删除缓存的数据
|
||||
*/
|
||||
void del(String key);
|
||||
/**
|
||||
* 根据key删除缓存的数据
|
||||
*/
|
||||
void del(String key);
|
||||
|
||||
|
||||
/**
|
||||
* 判断是否存在一个key
|
||||
* */
|
||||
boolean contains(String key);
|
||||
|
||||
/**
|
||||
* 设置key过期时间
|
||||
* */
|
||||
void expire(String key, long timeout);
|
||||
|
||||
/**
|
||||
* 判断是否存在一个key
|
||||
*/
|
||||
boolean contains(String key);
|
||||
|
||||
/**
|
||||
* 设置key过期时间
|
||||
*/
|
||||
void expire(String key, long timeout);
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,23 +1,35 @@
|
||||
package com.java2nb.novel.core.cache.impl;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author xxy
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class RedisServiceImpl implements CacheService {
|
||||
|
||||
private final StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
private final RedisTemplate<Object, Object> redisTemplate;
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@ -37,34 +49,66 @@ public class RedisServiceImpl implements CacheService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObject(String key) {
|
||||
return redisTemplate.opsForValue().get(key);
|
||||
public <T> T getObject(String key, Class<T> clazz) {
|
||||
String result = get(key);
|
||||
if (result != null) {
|
||||
try {
|
||||
return objectMapper.readValue(result, clazz);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> getList(String key, Class<T> clazz) {
|
||||
String result = get(key);
|
||||
if (result != null) {
|
||||
try {
|
||||
return objectMapper.readValue(result,
|
||||
objectMapper.getTypeFactory().constructCollectionType(List.class, clazz));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject(String key, Object value) {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
if (value != null) {
|
||||
try {
|
||||
set(key, objectMapper.writeValueAsString(value));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject(String key, Object value, long timeout) {
|
||||
redisTemplate.opsForValue().set(key, value, timeout, TimeUnit.SECONDS);
|
||||
if (value != null) {
|
||||
try {
|
||||
set(key, objectMapper.writeValueAsString(value), timeout);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(String key) {
|
||||
redisTemplate.delete(key);
|
||||
stringRedisTemplate.delete(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(String key) {
|
||||
return redisTemplate.hasKey(key) || stringRedisTemplate.hasKey(key);
|
||||
return stringRedisTemplate.hasKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void expire(String key, long timeout) {
|
||||
redisTemplate.expire(key, timeout, TimeUnit.SECONDS);
|
||||
stringRedisTemplate.expire(key, timeout, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,10 @@ http:
|
||||
# 是否开启 HTTP 代理,true-开启,false-不开启
|
||||
enabled: false
|
||||
# 代理 IP
|
||||
ip: us.swiftproxy.net
|
||||
ip: proxy.bestproxy.com
|
||||
# 代理端口号
|
||||
port: 7878
|
||||
port: 2312
|
||||
# 代理用户名
|
||||
username: swiftproxy_u
|
||||
username: bestproxy_u
|
||||
# 代理密码
|
||||
password: swiftproxy_p
|
||||
password: bestproxy_p
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>novel</artifactId>
|
||||
<groupId>com.java2nb</groupId>
|
||||
<version>5.2.3</version>
|
||||
<version>5.2.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -38,10 +38,10 @@ http:
|
||||
# 是否开启 HTTP 代理,true-开启,false-不开启
|
||||
enabled: false
|
||||
# 代理 IP
|
||||
ip: us.swiftproxy.net
|
||||
ip: proxy.bestproxy.com
|
||||
# 代理端口号
|
||||
port: 7878
|
||||
port: 2312
|
||||
# 代理用户名
|
||||
username: swiftproxy_u
|
||||
username: bestproxy_u
|
||||
# 代理密码
|
||||
password: swiftproxy_p
|
||||
password: bestproxy_p
|
@ -72,17 +72,15 @@ public class CrawlController {
|
||||
if(url.startsWith("https://")||url.startsWith("http://")){
|
||||
String refreshCache="1";
|
||||
if(!refreshCache.equals(isRefresh)) {
|
||||
Object cache = cacheService.getObject(CacheKey.BOOK_TEST_PARSE + url);
|
||||
if (cache == null) {
|
||||
html = cacheService.get(CacheKey.BOOK_TEST_PARSE + url);
|
||||
if (html == null) {
|
||||
isRefresh="1";
|
||||
}else {
|
||||
html = (String) cache;
|
||||
}
|
||||
}
|
||||
if(refreshCache.equals(isRefresh)){
|
||||
html = HttpUtil.getByHttpClientWithChrome(url);
|
||||
if (html != null) {
|
||||
cacheService.setObject(CacheKey.BOOK_TEST_PARSE + url, html, 60 * 10);
|
||||
cacheService.set(CacheKey.BOOK_TEST_PARSE + url, html, 60 * 10);
|
||||
}else{
|
||||
resultMap.put("msg","html is null");
|
||||
return RestResult.ok(resultMap);
|
||||
|
@ -12,7 +12,6 @@ import io.github.xxyopen.util.IdWorker;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>novel</artifactId>
|
||||
<groupId>com.java2nb</groupId>
|
||||
<version>5.2.3</version>
|
||||
<version>5.2.5</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -96,6 +96,16 @@
|
||||
<include name="application-website.yml"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${basedir}/../templates/green/html" overwrite="true">
|
||||
<fileset dir="${basedir}/src/main/resources/templates">
|
||||
<include name="**/*.*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${basedir}/../templates/green/static" overwrite="true">
|
||||
<fileset dir="${basedir}/src/main/resources/static">
|
||||
<include name="**/*.*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${project.build.directory}/build/templates" overwrite="true">
|
||||
<fileset dir="${basedir}/../templates">
|
||||
<include name="**/*.*"/>
|
||||
|
@ -41,13 +41,13 @@ http:
|
||||
# 是否开启 HTTP 代理,true-开启,false-不开启
|
||||
enabled: false
|
||||
# 代理 IP
|
||||
ip: us.swiftproxy.net
|
||||
ip: proxy.bestproxy.com
|
||||
# 代理端口号
|
||||
port: 7878
|
||||
port: 2312
|
||||
# 代理用户名
|
||||
username: swiftproxy_u
|
||||
username: bestproxy_u
|
||||
# 代理密码
|
||||
password: swiftproxy_p
|
||||
password: bestproxy_p
|
||||
|
||||
|
||||
--- #--------------------- Spring AI 配置----------------------
|
||||
|
@ -110,20 +110,6 @@ public class AuthorController extends BaseController {
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新章节名
|
||||
*/
|
||||
@PostMapping("updateIndexName")
|
||||
public RestResult<Void> updateIndexName(Long indexId, String indexName, HttpServletRequest request) {
|
||||
|
||||
Author author = checkAuthor(request);
|
||||
|
||||
//更新章节名
|
||||
bookService.updateIndexName(indexId, indexName, author.getId());
|
||||
|
||||
return RestResult.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 发布章节内容
|
||||
|
@ -43,7 +43,7 @@ public class BookController extends BaseController {
|
||||
* 查询首页小说设置列表数据
|
||||
*/
|
||||
@GetMapping("listBookSetting")
|
||||
public RestResult<Map<Byte, List<BookSettingVO>>> listBookSetting() {
|
||||
public RestResult<Map<String, List<BookSettingVO>>> listBookSetting() {
|
||||
return RestResult.ok(bookService.listBookSettingVO());
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class PageController extends BaseController {
|
||||
@RequestMapping(path = {"/", "/index", "/index.html"})
|
||||
public String index(Model model) {
|
||||
//加载小说首页小说基本信息线程
|
||||
CompletableFuture<Map<Byte, List<BookSettingVO>>> bookCompletableFuture = CompletableFuture.supplyAsync(
|
||||
CompletableFuture<Map<String, List<BookSettingVO>>> bookCompletableFuture = CompletableFuture.supplyAsync(
|
||||
bookService::listBookSettingVO, threadPoolExecutor);
|
||||
//加载首页新闻线程
|
||||
CompletableFuture<List<News>> newsCompletableFuture = CompletableFuture.supplyAsync(newsService::listIndexNews,
|
||||
|
@ -16,9 +16,10 @@ public interface BookService {
|
||||
|
||||
/**
|
||||
* 查询首页小说设置列表数据
|
||||
*
|
||||
* @return
|
||||
* */
|
||||
Map<Byte, List<BookSettingVO>> listBookSettingVO();
|
||||
*/
|
||||
Map<String, List<BookSettingVO>> listBookSettingVO();
|
||||
|
||||
/**
|
||||
* 查询首页点击榜单数据
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.java2nb.novel.service.impl;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.java2nb.novel.core.cache.CacheKey;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
@ -25,7 +24,6 @@ import io.github.xxyopen.web.util.BeanUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.utils.DateUtils;
|
||||
import org.mybatis.dynamic.sql.SortSpecification;
|
||||
import org.mybatis.dynamic.sql.render.RenderingStrategies;
|
||||
@ -48,7 +46,6 @@ import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.java2nb.novel.mapper.BookCategoryDynamicSqlSupport.bookCategory;
|
||||
import static com.java2nb.novel.mapper.BookCategoryDynamicSqlSupport.sort;
|
||||
import static com.java2nb.novel.mapper.BookCommentDynamicSqlSupport.bookComment;
|
||||
import static com.java2nb.novel.mapper.BookContentDynamicSqlSupport.bookContent;
|
||||
import static com.java2nb.novel.mapper.BookContentDynamicSqlSupport.content;
|
||||
@ -108,19 +105,19 @@ public class BookServiceImpl implements BookService {
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public Map<Byte, List<BookSettingVO>> listBookSettingVO() {
|
||||
String result = cacheService.get(CacheKey.INDEX_BOOK_SETTINGS_KEY);
|
||||
if (result == null || result.length() < Constants.OBJECT_JSON_CACHE_EXIST_LENGTH) {
|
||||
List<BookSettingVO> list = bookSettingMapper.listVO();
|
||||
if (list.size() == 0) {
|
||||
public Map<String, List<BookSettingVO>> listBookSettingVO() {
|
||||
List<BookSettingVO> list = cacheService.getList(CacheKey.INDEX_BOOK_SETTINGS_KEY, BookSettingVO.class);
|
||||
if (list == null || list.isEmpty()) {
|
||||
list = bookSettingMapper.listVO();
|
||||
if (list.isEmpty()) {
|
||||
//如果首页小说没有被设置,则初始化首页小说设置
|
||||
list = initIndexBookSetting();
|
||||
}
|
||||
result = new ObjectMapper().writeValueAsString(
|
||||
list.stream().collect(Collectors.groupingBy(BookSettingVO::getType)));
|
||||
cacheService.set(CacheKey.INDEX_BOOK_SETTINGS_KEY, result, 3600 * 24);
|
||||
cacheService.setObject(CacheKey.INDEX_BOOK_SETTINGS_KEY, list, 3600 * 24);
|
||||
}
|
||||
return new ObjectMapper().readValue(result, Map.class);
|
||||
return list.stream().collect(
|
||||
Collectors.groupingBy(book -> book.getType().toString())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -170,11 +167,10 @@ public class BookServiceImpl implements BookService {
|
||||
return new ArrayList<>(0);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Book> listClickRank() {
|
||||
List<Book> result = (List<Book>) cacheService.getObject(CacheKey.INDEX_CLICK_BANK_BOOK_KEY);
|
||||
if (result == null || result.size() == 0) {
|
||||
List<Book> result = cacheService.getList(CacheKey.INDEX_CLICK_BANK_BOOK_KEY, Book.class);
|
||||
if (result == null || result.isEmpty()) {
|
||||
result = listRank((byte) 0, 10);
|
||||
cacheService.setObject(CacheKey.INDEX_CLICK_BANK_BOOK_KEY, result, 5000);
|
||||
}
|
||||
@ -183,8 +179,8 @@ public class BookServiceImpl implements BookService {
|
||||
|
||||
@Override
|
||||
public List<Book> listNewRank() {
|
||||
List<Book> result = (List<Book>) cacheService.getObject(CacheKey.INDEX_NEW_BOOK_KEY);
|
||||
if (result == null || result.size() == 0) {
|
||||
List<Book> result = cacheService.getList(CacheKey.INDEX_NEW_BOOK_KEY, Book.class);
|
||||
if (result == null || result.isEmpty()) {
|
||||
result = listRank((byte) 1, 10);
|
||||
cacheService.setObject(CacheKey.INDEX_NEW_BOOK_KEY, result, 3600);
|
||||
}
|
||||
@ -193,8 +189,8 @@ public class BookServiceImpl implements BookService {
|
||||
|
||||
@Override
|
||||
public List<BookVO> listUpdateRank() {
|
||||
List<BookVO> result = (List<BookVO>) cacheService.getObject(CacheKey.INDEX_UPDATE_BOOK_KEY);
|
||||
if (result == null || result.size() == 0) {
|
||||
List<BookVO> result = cacheService.getList(CacheKey.INDEX_UPDATE_BOOK_KEY, BookVO.class);
|
||||
if (result == null || result.isEmpty()) {
|
||||
List<Book> bookPOList = listRank((byte) 2, 23);
|
||||
result = BeanUtil.copyList(bookPOList, BookVO.class);
|
||||
cacheService.setObject(CacheKey.INDEX_UPDATE_BOOK_KEY, result, 60 * 10);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.java2nb.novel.service.impl;
|
||||
|
||||
import io.github.xxyopen.web.util.BeanUtil;
|
||||
import com.java2nb.novel.service.FriendLinkService;
|
||||
import com.java2nb.novel.core.cache.CacheKey;
|
||||
import com.java2nb.novel.core.cache.CacheService;
|
||||
@ -31,16 +30,16 @@ public class FriendLinkServiceImpl implements FriendLinkService {
|
||||
|
||||
@Override
|
||||
public List<FriendLink> listIndexLink() {
|
||||
List<FriendLink> result = (List<FriendLink>) cacheService.getObject(CacheKey.INDEX_LINK_KEY);
|
||||
if(result == null || result.size() == 0) {
|
||||
SelectStatementProvider selectStatement = select(linkName,linkUrl)
|
||||
.from(friendLink)
|
||||
.where(isOpen,isEqualTo((byte)1))
|
||||
.orderBy(sort)
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
result = friendLinkMapper.selectMany(selectStatement);
|
||||
cacheService.setObject(CacheKey.INDEX_LINK_KEY,result,60 * 60 * 24);
|
||||
List<FriendLink> result = cacheService.getList(CacheKey.INDEX_LINK_KEY, FriendLink.class);
|
||||
if (result == null || result.isEmpty()) {
|
||||
SelectStatementProvider selectStatement = select(linkName, linkUrl)
|
||||
.from(friendLink)
|
||||
.where(isOpen, isEqualTo((byte) 1))
|
||||
.orderBy(sort)
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
result = friendLinkMapper.selectMany(selectStatement);
|
||||
cacheService.setObject(CacheKey.INDEX_LINK_KEY, result, 60 * 60 * 24);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import com.java2nb.novel.service.LikeService;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
||||
import org.springframework.scripting.support.StaticScriptSource;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -20,7 +20,7 @@ import java.util.Collections;
|
||||
@Slf4j
|
||||
public class LikeServiceImpl implements LikeService {
|
||||
|
||||
private final RedisTemplate<Object, Object> redisTemplate;
|
||||
private final StringRedisTemplate redisTemplate;
|
||||
|
||||
private DefaultRedisScript<Long> toggleLikeScript;
|
||||
|
||||
@ -33,19 +33,19 @@ public class LikeServiceImpl implements LikeService {
|
||||
public void init() {
|
||||
// Lua 脚本保证原子性操作
|
||||
String script = """
|
||||
local key = KEYS[1]
|
||||
local userId = ARGV[1]
|
||||
|
||||
local isLiked = redis.call('SISMEMBER', key, userId)
|
||||
|
||||
if isLiked == 1 then
|
||||
redis.call('SREM', key, userId)
|
||||
else
|
||||
redis.call('SADD', key, userId)
|
||||
end
|
||||
|
||||
return redis.call('SCARD', key)
|
||||
""";
|
||||
local key = KEYS[1]
|
||||
local userId = ARGV[1]
|
||||
|
||||
local isLiked = redis.call('SISMEMBER', key, userId)
|
||||
|
||||
if isLiked == 1 then
|
||||
redis.call('SREM', key, userId)
|
||||
else
|
||||
redis.call('SADD', key, userId)
|
||||
end
|
||||
|
||||
return redis.call('SCARD', key)
|
||||
""";
|
||||
|
||||
toggleLikeScript = new DefaultRedisScript<>();
|
||||
toggleLikeScript.setScriptSource(new StaticScriptSource(script));
|
||||
@ -89,6 +89,6 @@ public class LikeServiceImpl implements LikeService {
|
||||
}
|
||||
|
||||
private Long executeToggle(String key, Long userId) {
|
||||
return redisTemplate.execute(toggleLikeScript, Collections.singletonList(key), userId);
|
||||
return redisTemplate.execute(toggleLikeScript, Collections.singletonList(key), String.valueOf(userId));
|
||||
}
|
||||
}
|
||||
|
@ -36,16 +36,16 @@ public class NewsServiceImpl implements NewsService {
|
||||
|
||||
@Override
|
||||
public List<News> listIndexNews() {
|
||||
List<News> result = (List<News>) cacheService.getObject(CacheKey.INDEX_NEWS_KEY);
|
||||
if(result == null || result.size() == 0) {
|
||||
SelectStatementProvider selectStatement = select(id, catName, catId, title,createTime)
|
||||
.from(news)
|
||||
.orderBy(createTime.descending())
|
||||
.limit(2)
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
List<News> result = cacheService.getList(CacheKey.INDEX_NEWS_KEY, News.class);
|
||||
if (result == null || result.isEmpty()) {
|
||||
SelectStatementProvider selectStatement = select(id, catName, catId, title, createTime)
|
||||
.from(news)
|
||||
.orderBy(createTime.descending())
|
||||
.limit(2)
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
result = newsMapper.selectMany(selectStatement);
|
||||
cacheService.setObject(CacheKey.INDEX_NEWS_KEY,result,60 * 60 * 12);
|
||||
cacheService.setObject(CacheKey.INDEX_NEWS_KEY, result, 60 * 60 * 12);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -53,25 +53,25 @@ public class NewsServiceImpl implements NewsService {
|
||||
@Override
|
||||
public News queryNewsInfo(Long newsId) {
|
||||
SelectStatementProvider selectStatement = select(news.allColumns())
|
||||
.from(news)
|
||||
.where(id,isEqualTo(newsId))
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
.from(news)
|
||||
.where(id, isEqualTo(newsId))
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
return newsMapper.selectMany(selectStatement).get(0);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageBean<News> listByPage(int page, int pageSize) {
|
||||
PageHelper.startPage(page,pageSize);
|
||||
SelectStatementProvider selectStatement = select(id, catName, catId, title,createTime)
|
||||
.from(news)
|
||||
.orderBy(createTime.descending())
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
PageHelper.startPage(page, pageSize);
|
||||
SelectStatementProvider selectStatement = select(id, catName, catId, title, createTime)
|
||||
.from(news)
|
||||
.orderBy(createTime.descending())
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
List<News> news = newsMapper.selectMany(selectStatement);
|
||||
PageBean<News> pageBean = PageBuilder.build(news);
|
||||
pageBean.setList(BeanUtil.copyList(news,NewsVO.class));
|
||||
pageBean.setList(BeanUtil.copyList(news, NewsVO.class));
|
||||
return pageBean;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
@ -16,8 +14,6 @@
|
||||
|
||||
<div th:include="mobile/common/css :: css"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
|
||||
@ -62,6 +58,15 @@
|
||||
height: 180px;
|
||||
}
|
||||
|
||||
.book_desc {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@ -187,19 +192,19 @@
|
||||
book.bookDesc = book.bookDesc.replace(/<[^>]+>/g, "").replace(/\s+/g, "").replace(/ /g, "");
|
||||
}
|
||||
|
||||
bookListHtml += ("<div class=\"layui-row\" style=\"margin-bottom:10px;padding:10px;background: #f2f2f2\">\n" +
|
||||
bookListHtml += ("<div class=\"layui-row\" style=\"margin-bottom:10px;padding:5px 0px;background: #f2f2f2\">\n" +
|
||||
" <a href=\"/book/" + book.id + ".html\">\n" +
|
||||
" <div class=\"layui-col-xs6 layui-col-sm3 layui-col-md2 layui-col-lg2\" style=\"text-align: center\">\n" +
|
||||
" <img style='width: 130px;height: 180px' align=\"center\"\n" +
|
||||
" <div class=\"layui-col-xs5 layui-col-sm3 layui-col-md2 layui-col-lg2\" style=\"text-align: center\">\n" +
|
||||
" <img style='width: 130px;height: 190px' align=\"center\"\n" +
|
||||
" src=\"" + book.picUrl + "\"/>\n" +
|
||||
"\n" +
|
||||
" </div>\n" +
|
||||
" </a>\n" +
|
||||
" <div style=\"padding: 10px\" class=\"layui-col-xs6 layui-col-sm8 layui-col-md8 layui-col-lg8\">\n" +
|
||||
" <div style=\"padding: 0px 10px 0px 0px\" class=\"layui-col-xs7 layui-col-sm9 layui-col-md10 layui-col-lg10\">\n" +
|
||||
" <a href=\"/book/" + book.id + ".html\">\n" +
|
||||
" <div class=\"line-limit-length\" style=\";color: #000;font-size: 15px\">" + book.bookName + "</div>\n" +
|
||||
" </a>\n" +
|
||||
" <div style=\";color: #4c6978;float: right;\"><i style=\"color: red\"></i></div>\n" +
|
||||
" <div style=\"height: 5px;color: #4c6978;\"><i style=\"color: red\"></i></div>\n" +
|
||||
" <a href=\"/book/book_ranking.html?keyword=" + encodeURI(book.authorName) + "\">\n" +
|
||||
" <div style=\";color: #a6a6a6;\" class=\"line-limit-length\">作者:" + book.authorName + "</div>\n" +
|
||||
" </a>\n" +
|
||||
@ -207,7 +212,7 @@
|
||||
" <div style=\"margin-top: 5px;color: #a6a6a6;\">状态:" + (book.bookStatus == 0 ? '连载' : '完结') + "</div>\n" +
|
||||
" <div style=\"margin-top: 5px;color: #a6a6a6;\">更新:<i style='color: red'>" + book.lastIndexUpdateTime.substr(0, 11) + "</i>\n" +
|
||||
" </div>\n" +
|
||||
" <div style=\"margin-top: 5px;color: #a6a6a6;\">简介:" + (book.bookDesc ? (book.bookDesc.length > 15 ? (book.bookDesc.substr(0, 15) + "...") : book.bookDesc) : book.bookDesc) + "</div>\n" +
|
||||
" <div class='book_desc' style=\"margin-top: 5px;color: #a6a6a6;\">简介:" + (book.bookDesc) + "</div>\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" </div>\n" +
|
||||
|
@ -26,6 +26,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
.book_name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
#footer {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
|
@ -53,6 +53,44 @@
|
||||
color: #3eaf7c;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
overflow-x: auto; /* 允许内容水平滚动 */
|
||||
white-space: nowrap; /* 禁止换行 */
|
||||
scroll-snap-type: x mandatory; /* 在滚动时强制对齐 snap-points */
|
||||
-ms-overflow-style: none; /* Internet Explorer 10+ */
|
||||
scrollbar-width: none; /* Firefox */
|
||||
}
|
||||
|
||||
.container::-webkit-scrollbar {
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.container::-webkit-scrollbar-track,
|
||||
.container::-webkit-scrollbar-thumb {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
.item {
|
||||
flex: 0 0 calc(100% / 10); /* 每个元素宽度为容器的十分之一 */
|
||||
scroll-snap-align: start;
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
border-radius: 5px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.book_desc {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
@ -107,60 +145,58 @@
|
||||
精品推荐
|
||||
</blockquote>
|
||||
|
||||
<div class="container" style="padding-bottom: 10px">
|
||||
|
||||
<div class="layui-container" style="padding: 0px">
|
||||
<div class="item" style="position: relative;padding:1%;" th:if="${bookMap['4']}" th:each="book,iterStat:${bookMap['4']}">
|
||||
<a th:href="'/book/'+${book.bookId}+'.html'">
|
||||
|
||||
<div class="layui-row" style="text-align: center" id="currentWeek" th:if="${bookMap['4']}">
|
||||
<span th:each="book,iterStat : ${bookMap['4']}" th:if="${iterStat.index<3}">
|
||||
<a th:href="'/book/'+${book.bookId}+'.html'">
|
||||
<div style="padding: 1%" class="layui-col-xs4 layui-col-sm4 layui-col-md4 layui-col-lg4">
|
||||
<img style=" width:100px; height:125px; max-width:100%; max-height:100%;"
|
||||
th:src="${book.picUrl}">
|
||||
<img style=" width:100px; height:125px; max-width:100%; max-height:100%;"
|
||||
th:src="${book.picUrl}">
|
||||
<br>
|
||||
<span style="width: 100px" class="book_name" th:text="${book.bookName}"></span>
|
||||
|
||||
<br>
|
||||
<span th:text="${#strings.length(book.bookName) > 5}? (${#strings.substring(book.bookName,0,5)}+'...'): ${book.bookName} "></span>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-colla-item">
|
||||
<blockquote class="layui-elem-quote" style="text-align: left;font-size: 16px">
|
||||
热门推荐
|
||||
</blockquote>
|
||||
|
||||
<div class="layui-container">
|
||||
<div class="layui-row" id="hotRecBooks" th:if="${bookMap['3']}">
|
||||
<div th:each="book,iterStat : ${bookMap['3']}" th:if="${iterStat.index<6}" style="margin-bottom: 5px"
|
||||
class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
|
||||
<a th:href="'/book/'+${book.bookId}+'.html'">
|
||||
<div class="layui-col-xs5 layui-col-sm4 layui-col-md4 layui-col-lg4">
|
||||
<img style=" width:100px; height:125px;" th:src="${book.picUrl}">
|
||||
|
||||
</div>
|
||||
<div class="layui-col-xs5 layui-col-sm6 layui-col-md6 layui-col-lg6">
|
||||
<ul>
|
||||
<li style="padding-bottom: 2px" class="line-limit-length"
|
||||
th:text="${book.bookName}"></li>
|
||||
<li style="padding-bottom: 2px;color: #a6a6a6" th:text="'作者:'+${book.authorName}"></li>
|
||||
<li style="color: #a6a6a6;width: 180px;height:60px;overflow: hidden"
|
||||
th:utext="${book.bookDesc}"></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div style="font-style: italic;color: red"
|
||||
class="layui-col-xs2 layui-col-sm2 layui-col-md2 layui-col-lg2"></div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
<div class="layui-colla-item">
|
||||
<blockquote class="layui-elem-quote" style="text-align: left;font-size: 16px">
|
||||
热门推荐
|
||||
</blockquote>
|
||||
|
||||
<div class="layui-container">
|
||||
<div class="layui-row" id="hotRecBooks" th:if="${bookMap['3']}">
|
||||
<div th:each="book,iterStat : ${bookMap['3']}" th:if="${iterStat.index<6}" style="margin-bottom: 5px"
|
||||
class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
|
||||
<a th:href="'/book/'+${book.bookId}+'.html'">
|
||||
<div class="layui-col-xs4 layui-col-sm4 layui-col-md4 layui-col-lg4">
|
||||
<img style=" width:100px; height:125px;" th:src="${book.picUrl}">
|
||||
|
||||
</div>
|
||||
<div class="layui-col-xs8 layui-col-sm8 layui-col-md8 layui-col-lg8">
|
||||
<ul>
|
||||
<li style="padding-bottom: 5px" class="line-limit-length"
|
||||
th:text="${book.bookName}"></li>
|
||||
<li style="padding-bottom: 5px;color: #a6a6a6" th:text="'作者:'+${book.authorName}"></li>
|
||||
<li class='book_desc' style="color: #a6a6a6;padding-right:10px;"
|
||||
th:utext="${book.bookDesc}"></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div style="font-style: italic;color: red"
|
||||
class="layui-col-xs2 layui-col-sm2 layui-col-md2 layui-col-lg2"></div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
<div style="height: 1px" class="layui-col-lg1"></div>
|
||||
@ -184,7 +220,6 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="clear: both"></div>
|
||||
<div th:replace="mobile/common/footer :: footer">
|
||||
@ -226,7 +261,7 @@
|
||||
"\n" +
|
||||
" <div style=\"clear: both\"></div>\n" +
|
||||
" <div style=\"color: #a6a6a6;padding-left: 5px;padding-top: 5px\"\n" +
|
||||
" class=\"layui-elip layui-col-md11 layui-col-sm11 layui-col-lg11\">简介: " + updateRankBook.bookDesc + "" +
|
||||
" class=\"layui-elip layui-col-md11 layui-col-sm11 layui-col-lg11\">简介:" + updateRankBook.bookDesc + "" +
|
||||
" </div></a>\n" +
|
||||
" </div>");
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.java2nb</groupId>
|
||||
<artifactId>novel</artifactId>
|
||||
<version>5.2.3</version>
|
||||
<version>5.2.5</version>
|
||||
<modules>
|
||||
<module>novel-common</module>
|
||||
<module>novel-front</module>
|
||||
|
216
templates/green/html/book/book_comment_reply.html
Normal file
216
templates/green/html/book/book_comment_reply.html
Normal file
@ -0,0 +1,216 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head th:replace="common/header :: common_head(~{::title},~{},~{::link},~{})">
|
||||
<title th:text="'评论回复区'"></title>
|
||||
<link href="/css/main.css" rel="stylesheet"/>
|
||||
<link href="/css/book.css" rel="stylesheet"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<input type="hidden" id="commentId" th:value="${commentId}"/>
|
||||
|
||||
<div th:replace="common/top :: top('')">
|
||||
</div>
|
||||
|
||||
<div class="main box_center cf mb50">
|
||||
<div class="channelBookContent cf">
|
||||
<!--left start-->
|
||||
<div class="wrap_left fl">
|
||||
<div class="wrap_bg">
|
||||
<div class="pad20">
|
||||
|
||||
<div class="bookComment">
|
||||
<div class="book_tit">
|
||||
<div class="fl">
|
||||
<h3>评论回复区</h3><span id="bookCommentTotal">(0条)</span>
|
||||
</div>
|
||||
<a class="fr" href="#txtComment">发表回复</a>
|
||||
</div>
|
||||
<blockquote class="layui-elem-quote" th:utext="${commentContent}">
|
||||
</blockquote>
|
||||
<div class="no_comment" id="noCommentPanel" style="display: none;">
|
||||
<img src="/images/no_comment.png" alt=""/>
|
||||
<span class="block">暂无回复</span>
|
||||
</div>
|
||||
<div class="commentBar" id="commentPanel">
|
||||
|
||||
</div>
|
||||
<div class="pageBox cf mt15 mr10" id="commentPage">
|
||||
</div>
|
||||
|
||||
<div class="reply_bar" id="reply_bar">
|
||||
<div class="tit">
|
||||
<span class="fl font16">发表回复</span>
|
||||
<!--未登录状态下不可发表评论,显示以下链接-->
|
||||
<span class="fr black9" style="display:none; ">请先 <a class="orange"
|
||||
href="/user/login.html">登录</a><em
|
||||
class="ml10 mr10">|</em><a class="orange"
|
||||
href="/user/register.html">注册</a></span>
|
||||
</div>
|
||||
<textarea name="txtComment" rows="2" cols="20" id="txtComment" class="replay_text"
|
||||
placeholder="我来说两句..."></textarea>
|
||||
<div class="reply_btn">
|
||||
<span class="fl black9"><em class="ml5" id="emCommentNum">0/1000</em> 字</span>
|
||||
<span class="fr"><a class="btn_ora" href="javascript:void(0);"
|
||||
onclick="javascript:BookDetail.SaveCommentReply(37,0,$('#txtComment').val());">发表</a></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--left end-->
|
||||
|
||||
<!--right start-->
|
||||
|
||||
<!--right end-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div th:replace="common/footer :: footer">
|
||||
</div>
|
||||
<div th:replace="common/js :: js"></div>
|
||||
<script src="/javascript/bookdetail.js" type="text/javascript"></script>
|
||||
<script language="javascript" type="text/javascript">
|
||||
$('#txtComment').on('input propertychange', function () {
|
||||
var count = $(this).val().length;
|
||||
$('#emCommentNum').html(count + "/1000");
|
||||
if (count > 1000) {
|
||||
$('#txtComment').val($('#txtComment').val().substring(0, 1000));
|
||||
}
|
||||
});
|
||||
loadCommentList(1, 20);
|
||||
|
||||
function loadCommentList(curr, limit) {
|
||||
|
||||
$.ajax({
|
||||
type: "get",
|
||||
url: "/book/listCommentReplyByPage",
|
||||
data: {'commentId': $("#commentId").val(), 'curr': curr, 'limit': limit},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
if (data.data.total == 0) {
|
||||
$("#noCommentPanel").css("display", "block");
|
||||
$("#commentPanel").css("display", "none");
|
||||
return;
|
||||
}
|
||||
$("#noCommentPanel").css("display", "none");
|
||||
$("#commentPanel").css("display", "block");
|
||||
var commentList = data.data.list;
|
||||
if (commentList.length > 0) {
|
||||
$("#bookCommentTotal").html("(" + data.data.total + "条)");
|
||||
var commentListHtml = "";
|
||||
for (var i = 0; i < commentList.length; i++) {
|
||||
var comment = commentList[i];
|
||||
commentListHtml += ("<div class=\"comment_list cf\">" +
|
||||
"<div class=\"user_heads fl\" vals=\"389\">" +
|
||||
"<img src=\"" + (comment.createUserPhoto ? comment.createUserPhoto : '/images/man.png') + "\" class=\"user_head\" alt=\"\">" +
|
||||
"<span class=\"user_level1\" style=\"display: none;\">见习</span></div>" +
|
||||
"<ul class=\"pl_bar fr\">\t\t\t<li class=\"name\">" + (comment.createUserName) + "<span style='padding-left: 10px' class=\"other\">" + (comment.location ? comment.location + "读者" : '') + "</span></li><li class=\"dec\">" +
|
||||
comment.replyContent +
|
||||
"</li><li class=\"other cf\">" +
|
||||
"<span class=\"time fl\" style='padding-right: 10px'>" + (data.data.total - ((curr - 1) * limit + i)) + "楼</span>" +
|
||||
"<span class=\"time fl\">" + comment.createTime + "</span>" +
|
||||
"<span class=\"fr\"><a href=\"javascript:toggleCommentUnLike('"+comment.id+"')\" class=\"zan\" style=\"padding-left: 10px\">踩<i class=\"num\" id='unLikeCount"+comment.id+"'>("+comment.unLikesCount+")</i></a></span>" +
|
||||
"<span class=\"fr\"><a href=\"javascript:toggleCommentLike('"+comment.id+"')\" class=\"zan\" style=\"padding-left: 10px\">赞<i class=\"num\" id='likeCount"+comment.id+"'>("+comment.likesCount+")</i></a></span>" +
|
||||
"</li>\t\t</ul>\t</div>");
|
||||
}
|
||||
$("#commentPanel").html(commentListHtml);
|
||||
|
||||
layui.use('laypage', function () {
|
||||
var laypage = layui.laypage;
|
||||
|
||||
//执行一个laypage实例
|
||||
laypage.render({
|
||||
elem: 'commentPage' //注意,这里的 test1 是 ID,不用加 # 号
|
||||
, count: data.data.total //数据总数,从服务端得到,
|
||||
, curr: data.data.pageNum
|
||||
, limit: data.data.pageSize
|
||||
, jump: function (obj, first) {
|
||||
|
||||
|
||||
//obj包含了当前分页的所有参数,比如:
|
||||
console.log(obj.curr); //得到当前页,以便向服务端请求对应页的数据。
|
||||
console.log(obj.limit); //得到每页显示的条数
|
||||
|
||||
|
||||
//首次不执行
|
||||
if (!first) {
|
||||
loadCommentList(obj.curr, obj.limit);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
layer.alert(data.msg);
|
||||
}
|
||||
|
||||
},
|
||||
error: function () {
|
||||
layer.alert('网络异常');
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function toggleCommentLike(replyId) {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "/book/toggleReplyLike",
|
||||
data: {'replyId': replyId},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
$("#likeCount"+replyId).text("("+data.data+")")
|
||||
} else if (data.code == 1001) {
|
||||
//未登录
|
||||
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
|
||||
|
||||
} else {
|
||||
layer.alert(data.msg);
|
||||
}
|
||||
|
||||
},
|
||||
error: function () {
|
||||
layer.alert('网络异常');
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function toggleCommentUnLike(replyId) {
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: "/book/toggleReplyUnLike",
|
||||
data: {'replyId': replyId},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
$("#unLikeCount"+replyId).text("("+data.data+")")
|
||||
} else if (data.code == 1001) {
|
||||
//未登录
|
||||
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
|
||||
|
||||
} else {
|
||||
layer.alert(data.msg);
|
||||
}
|
||||
|
||||
},
|
||||
error: function () {
|
||||
layer.alert('网络异常');
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,6 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
@ -16,8 +14,6 @@
|
||||
|
||||
<div th:include="mobile/common/css :: css"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
|
||||
@ -62,6 +58,15 @@
|
||||
height: 180px;
|
||||
}
|
||||
|
||||
.book_desc {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@ -187,19 +192,19 @@
|
||||
book.bookDesc = book.bookDesc.replace(/<[^>]+>/g, "").replace(/\s+/g, "").replace(/ /g, "");
|
||||
}
|
||||
|
||||
bookListHtml += ("<div class=\"layui-row\" style=\"margin-bottom:10px;padding:10px;background: #f2f2f2\">\n" +
|
||||
bookListHtml += ("<div class=\"layui-row\" style=\"margin-bottom:10px;padding:5px 0px;background: #f2f2f2\">\n" +
|
||||
" <a href=\"/book/" + book.id + ".html\">\n" +
|
||||
" <div class=\"layui-col-xs6 layui-col-sm3 layui-col-md2 layui-col-lg2\" style=\"text-align: center\">\n" +
|
||||
" <img style='width: 130px;height: 180px' align=\"center\"\n" +
|
||||
" <div class=\"layui-col-xs5 layui-col-sm3 layui-col-md2 layui-col-lg2\" style=\"text-align: center\">\n" +
|
||||
" <img style='width: 130px;height: 190px' align=\"center\"\n" +
|
||||
" src=\"" + book.picUrl + "\"/>\n" +
|
||||
"\n" +
|
||||
" </div>\n" +
|
||||
" </a>\n" +
|
||||
" <div style=\"padding: 10px\" class=\"layui-col-xs6 layui-col-sm8 layui-col-md8 layui-col-lg8\">\n" +
|
||||
" <div style=\"padding: 0px 10px 0px 0px\" class=\"layui-col-xs7 layui-col-sm9 layui-col-md10 layui-col-lg10\">\n" +
|
||||
" <a href=\"/book/" + book.id + ".html\">\n" +
|
||||
" <div class=\"line-limit-length\" style=\";color: #000;font-size: 15px\">" + book.bookName + "</div>\n" +
|
||||
" </a>\n" +
|
||||
" <div style=\";color: #4c6978;float: right;\"><i style=\"color: red\"></i></div>\n" +
|
||||
" <div style=\"height: 5px;color: #4c6978;\"><i style=\"color: red\"></i></div>\n" +
|
||||
" <a href=\"/book/book_ranking.html?keyword=" + encodeURI(book.authorName) + "\">\n" +
|
||||
" <div style=\";color: #a6a6a6;\" class=\"line-limit-length\">作者:" + book.authorName + "</div>\n" +
|
||||
" </a>\n" +
|
||||
@ -207,7 +212,7 @@
|
||||
" <div style=\"margin-top: 5px;color: #a6a6a6;\">状态:" + (book.bookStatus == 0 ? '连载' : '完结') + "</div>\n" +
|
||||
" <div style=\"margin-top: 5px;color: #a6a6a6;\">更新:<i style='color: red'>" + book.lastIndexUpdateTime.substr(0, 11) + "</i>\n" +
|
||||
" </div>\n" +
|
||||
" <div style=\"margin-top: 5px;color: #a6a6a6;\">简介:" + (book.bookDesc ? (book.bookDesc.length > 15 ? (book.bookDesc.substr(0, 15) + "...") : book.bookDesc) : book.bookDesc) + "</div>\n" +
|
||||
" <div class='book_desc' style=\"margin-top: 5px;color: #a6a6a6;\">简介:" + (book.bookDesc) + "</div>\n" +
|
||||
"\n" +
|
||||
"\n" +
|
||||
" </div>\n" +
|
||||
|
@ -26,6 +26,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
.book_name {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
#footer {
|
||||
position: absolute;
|
||||
bottom: 0px;
|
||||
|
@ -53,6 +53,44 @@
|
||||
color: #3eaf7c;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
overflow-x: auto; /* 允许内容水平滚动 */
|
||||
white-space: nowrap; /* 禁止换行 */
|
||||
scroll-snap-type: x mandatory; /* 在滚动时强制对齐 snap-points */
|
||||
-ms-overflow-style: none; /* Internet Explorer 10+ */
|
||||
scrollbar-width: none; /* Firefox */
|
||||
}
|
||||
|
||||
.container::-webkit-scrollbar {
|
||||
width: 0;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.container::-webkit-scrollbar-track,
|
||||
.container::-webkit-scrollbar-thumb {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
.item {
|
||||
flex: 0 0 calc(100% / 10); /* 每个元素宽度为容器的十分之一 */
|
||||
scroll-snap-align: start;
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
border-radius: 5px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.book_desc {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
@ -107,60 +145,58 @@
|
||||
精品推荐
|
||||
</blockquote>
|
||||
|
||||
<div class="container" style="padding-bottom: 10px">
|
||||
|
||||
<div class="layui-container" style="padding: 0px">
|
||||
<div class="item" style="position: relative;padding:1%;" th:if="${bookMap['4']}" th:each="book,iterStat:${bookMap['4']}">
|
||||
<a th:href="'/book/'+${book.bookId}+'.html'">
|
||||
|
||||
<div class="layui-row" style="text-align: center" id="currentWeek" th:if="${bookMap['4']}">
|
||||
<span th:each="book,iterStat : ${bookMap['4']}" th:if="${iterStat.index<3}">
|
||||
<a th:href="'/book/'+${book.bookId}+'.html'">
|
||||
<div style="padding: 1%" class="layui-col-xs4 layui-col-sm4 layui-col-md4 layui-col-lg4">
|
||||
<img style=" width:100px; height:125px; max-width:100%; max-height:100%;"
|
||||
th:src="${book.picUrl}">
|
||||
<img style=" width:100px; height:125px; max-width:100%; max-height:100%;"
|
||||
th:src="${book.picUrl}">
|
||||
<br>
|
||||
<span style="width: 100px" class="book_name" th:text="${book.bookName}"></span>
|
||||
|
||||
<br>
|
||||
<span th:text="${#strings.length(book.bookName) > 5}? (${#strings.substring(book.bookName,0,5)}+'...'): ${book.bookName} "></span>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-colla-item">
|
||||
<blockquote class="layui-elem-quote" style="text-align: left;font-size: 16px">
|
||||
热门推荐
|
||||
</blockquote>
|
||||
|
||||
<div class="layui-container">
|
||||
<div class="layui-row" id="hotRecBooks" th:if="${bookMap['3']}">
|
||||
<div th:each="book,iterStat : ${bookMap['3']}" th:if="${iterStat.index<6}" style="margin-bottom: 5px"
|
||||
class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
|
||||
<a th:href="'/book/'+${book.bookId}+'.html'">
|
||||
<div class="layui-col-xs5 layui-col-sm4 layui-col-md4 layui-col-lg4">
|
||||
<img style=" width:100px; height:125px;" th:src="${book.picUrl}">
|
||||
|
||||
</div>
|
||||
<div class="layui-col-xs5 layui-col-sm6 layui-col-md6 layui-col-lg6">
|
||||
<ul>
|
||||
<li style="padding-bottom: 2px" class="line-limit-length"
|
||||
th:text="${book.bookName}"></li>
|
||||
<li style="padding-bottom: 2px;color: #a6a6a6" th:text="'作者:'+${book.authorName}"></li>
|
||||
<li style="color: #a6a6a6;width: 180px;height:60px;overflow: hidden"
|
||||
th:utext="${book.bookDesc}"></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div style="font-style: italic;color: red"
|
||||
class="layui-col-xs2 layui-col-sm2 layui-col-md2 layui-col-lg2"></div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
<div class="layui-colla-item">
|
||||
<blockquote class="layui-elem-quote" style="text-align: left;font-size: 16px">
|
||||
热门推荐
|
||||
</blockquote>
|
||||
|
||||
<div class="layui-container">
|
||||
<div class="layui-row" id="hotRecBooks" th:if="${bookMap['3']}">
|
||||
<div th:each="book,iterStat : ${bookMap['3']}" th:if="${iterStat.index<6}" style="margin-bottom: 5px"
|
||||
class="layui-col-xs12 layui-col-sm6 layui-col-md4 layui-col-lg4">
|
||||
<a th:href="'/book/'+${book.bookId}+'.html'">
|
||||
<div class="layui-col-xs4 layui-col-sm4 layui-col-md4 layui-col-lg4">
|
||||
<img style=" width:100px; height:125px;" th:src="${book.picUrl}">
|
||||
|
||||
</div>
|
||||
<div class="layui-col-xs8 layui-col-sm8 layui-col-md8 layui-col-lg8">
|
||||
<ul>
|
||||
<li style="padding-bottom: 5px" class="line-limit-length"
|
||||
th:text="${book.bookName}"></li>
|
||||
<li style="padding-bottom: 5px;color: #a6a6a6" th:text="'作者:'+${book.authorName}"></li>
|
||||
<li class='book_desc' style="color: #a6a6a6;padding-right:10px;"
|
||||
th:utext="${book.bookDesc}"></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div style="font-style: italic;color: red"
|
||||
class="layui-col-xs2 layui-col-sm2 layui-col-md2 layui-col-lg2"></div>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
<div style="height: 1px" class="layui-col-lg1"></div>
|
||||
@ -184,7 +220,6 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="clear: both"></div>
|
||||
<div th:replace="mobile/common/footer :: footer">
|
||||
@ -226,7 +261,7 @@
|
||||
"\n" +
|
||||
" <div style=\"clear: both\"></div>\n" +
|
||||
" <div style=\"color: #a6a6a6;padding-left: 5px;padding-top: 5px\"\n" +
|
||||
" class=\"layui-elip layui-col-md11 layui-col-sm11 layui-col-lg11\">简介: " + updateRankBook.bookDesc + "" +
|
||||
" class=\"layui-elip layui-col-md11 layui-col-sm11 layui-col-lg11\">简介:" + updateRankBook.bookDesc + "" +
|
||||
" </div></a>\n" +
|
||||
" </div>");
|
||||
|
||||
|
@ -133,6 +133,52 @@
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
|
||||
SaveCommentReply: function (cmtBId, cmtCId, cmtDetail) {
|
||||
if (!isLogin) {
|
||||
layer.alert('请先登录');
|
||||
return;
|
||||
}
|
||||
var cmtDetailTemp = cmtDetail.replace(/(^\s*)/g, "");
|
||||
if (cmtDetailTemp == '') {
|
||||
layer.alert('回复内容必须填写');
|
||||
return;
|
||||
}
|
||||
if (cmtDetailTemp.length < 5) {
|
||||
layer.alert('回复内容必须大于5个字');
|
||||
return;
|
||||
}
|
||||
if (cmtDetail.length < 5) {
|
||||
layer.alert('回复内容必须大于5个字');
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/book/addCommentReply",
|
||||
data: {'commentId': $("#commentId").val(), 'replyContent': cmtDetail},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code == 200) {
|
||||
$('#txtComment').val("")
|
||||
layer.alert('回复成功!');
|
||||
loadCommentList(1, 20);
|
||||
|
||||
} else if (data.code == 1001) {
|
||||
//未登录
|
||||
location.href = '/user/login.html?originUrl=' + encodeURIComponent(location.href);
|
||||
|
||||
} else {
|
||||
layer.alert(data.msg);
|
||||
}
|
||||
|
||||
},
|
||||
error: function () {
|
||||
layer.alert('网络异常');
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
GetFavoritesBook: function (BId) {
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user