博客变为论坛,修改编辑器为正常编辑器

This commit is contained in:
limqhz
2022-05-05 01:11:09 +08:00
parent f701baaf04
commit 69941133b8
28 changed files with 457 additions and 187 deletions

16
pom.xml
View File

@@ -114,17 +114,11 @@
<artifactId>aliyun-sdk-oss</artifactId> <artifactId>aliyun-sdk-oss</artifactId>
<version>2.5.0</version> <version>2.5.0</version>
</dependency> </dependency>
<!-- <dependency>--> <!-- TEST -->
<!-- <groupId>org.springframework.boot</groupId>--> <dependency>
<!-- <artifactId>spring-boot-starter-test</artifactId>--> <groupId>org.springframework.boot</groupId>
<!-- <scope>test</scope>--> <artifactId>spring-boot-starter-test</artifactId>
<!-- <exclusions>--> </dependency>
<!-- <exclusion>-->
<!-- <groupId>org.junit.vintage</groupId>-->
<!-- <artifactId>junit-vintage-engine</artifactId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
</dependencies> </dependencies>
<!--打包插件--> <!--打包插件-->

View File

@@ -23,9 +23,9 @@ DROP TABLE IF EXISTS `qn_blog`;
CREATE TABLE `qn_blog` ( CREATE TABLE `qn_blog` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id', `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`bid` varchar(200) NOT NULL COMMENT '博客id', `bid` varchar(200) NOT NULL COMMENT '论坛id',
`title` varchar(200) NOT NULL COMMENT '博客标题', `title` varchar(200) NOT NULL COMMENT '论坛标题',
`content` longtext NOT NULL COMMENT '博客内容', `content` longtext NOT NULL COMMENT '论坛内容',
`sort` int(1) NOT NULL DEFAULT '0' COMMENT '排序 0 普通 1 置顶', `sort` int(1) NOT NULL DEFAULT '0' COMMENT '排序 0 普通 1 置顶',
`views` int(10) NOT NULL DEFAULT '0' COMMENT '浏览量', `views` int(10) NOT NULL DEFAULT '0' COMMENT '浏览量',
`author_id` varchar(200) NOT NULL COMMENT '作者id', `author_id` varchar(200) NOT NULL COMMENT '作者id',
@@ -44,7 +44,7 @@ DROP TABLE IF EXISTS `qn_blog_category`;
CREATE TABLE `qn_blog_category` ( CREATE TABLE `qn_blog_category` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id', `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`category` varchar(50) NOT NULL COMMENT '博客分类', `category` varchar(50) NOT NULL COMMENT '论坛分类',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8; ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;
@@ -55,7 +55,7 @@ DROP TABLE IF EXISTS `qn_comment`;
CREATE TABLE `qn_comment` ( CREATE TABLE `qn_comment` (
`id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id', `id` int(10) NOT NULL AUTO_INCREMENT COMMENT '自增id',
`comment_id` varchar(200) NOT NULL COMMENT '评论唯一id', `comment_id` varchar(200) NOT NULL COMMENT '评论唯一id',
`topic_category` int(1) NOT NULL COMMENT '1博客 2问答', `topic_category` int(1) NOT NULL COMMENT '1论坛 2问答',
`topic_id` varchar(200) NOT NULL COMMENT '评论主题id', `topic_id` varchar(200) NOT NULL COMMENT '评论主题id',
`user_id` varchar(200) NOT NULL COMMENT '评论者id', `user_id` varchar(200) NOT NULL COMMENT '评论者id',
`user_name` varchar(200) NOT NULL COMMENT '评论者昵称', `user_name` varchar(200) NOT NULL COMMENT '评论者昵称',

View File

@@ -3,6 +3,10 @@ package com.quinn.common;
public interface QuinnConstant { public interface QuinnConstant {
String LINK_SUFFIX = "."; String LINK_SUFFIX = ".";
/**
* REDIS PATTEN
*/
String REDIS_PATTEN = "*";
String GUN = "The emperor's new clothes"; String GUN = "The emperor's new clothes";

View File

@@ -113,7 +113,7 @@ public class SourceController {
*/ */
@GetMapping("/source/view/{sid}") @GetMapping("/source/view/{sid}")
public String read(@PathVariable("sid") String sid, Model model){ public String read(@PathVariable("sid") String sid, Model model){
Source source = sourceService.getOne(new QueryWrapper<Source>().eq("id", sid)); Source source = sourceService.hotResource(sid);
if(source != null){ if(source != null){
source.setSourceLink(QuinnConstant.GUN); source.setSourceLink(QuinnConstant.GUN);
} }

View File

@@ -47,7 +47,7 @@ public class UserController {
public String userIndex(@PathVariable String uid, Model model){ public String userIndex(@PathVariable String uid, Model model){
// 用户信息回填 // 用户信息回填
userInfoCallBack(uid,model); userInfoCallBack(uid,model);
// 用户的博客列表 // 用户的论坛列表
Page<Blog> pageParam = new Page<>(1, 10); Page<Blog> pageParam = new Page<>(1, 10);
blogService.page(pageParam,new QueryWrapper<Blog>().eq("author_id", uid) blogService.page(pageParam,new QueryWrapper<Blog>().eq("author_id", uid)
.orderByDesc("gmt_create")); .orderByDesc("gmt_create"));
@@ -66,7 +66,7 @@ public class UserController {
Model model){ Model model){
// 用户信息回填 // 用户信息回填
userInfoCallBack(uid,model); userInfoCallBack(uid,model);
// 用户的博客列表 // 用户的论坛列表
if (page < 1){ if (page < 1){
page = 1; page = 1;
} }
@@ -137,7 +137,7 @@ public class UserController {
String[] hobbys = userInfo.getHobby().split(","); String[] hobbys = userInfo.getHobby().split(",");
model.addAttribute("infoHobbys",hobbys); model.addAttribute("infoHobbys",hobbys);
} }
// 获取用户的问题,博客,回复数 // 获取用户的问题,论坛,回复数
int blogCount = blogService.count(new QueryWrapper<Blog>().eq("author_id", uid)); int blogCount = blogService.count(new QueryWrapper<Blog>().eq("author_id", uid));
int questionCount = questionService.count(new QueryWrapper<Question>().eq("author_id", uid)); int questionCount = questionService.count(new QueryWrapper<Question>().eq("author_id", uid));
int commentCount = commentService.count(new QueryWrapper<Comment>().eq("user_id", uid)); int commentCount = commentService.count(new QueryWrapper<Comment>().eq("user_id", uid));

View File

@@ -58,7 +58,7 @@ public class UserInfoController {
String[] hobbys = userInfo.getHobby().split(","); String[] hobbys = userInfo.getHobby().split(",");
model.addAttribute("infoHobbys",hobbys); model.addAttribute("infoHobbys",hobbys);
} }
// 获取用户的问题,博客,回复数 // 获取用户的问题,论坛,回复数
int blogCount = blogService.count(new QueryWrapper<Blog>().eq("author_id", uid)); int blogCount = blogService.count(new QueryWrapper<Blog>().eq("author_id", uid));
int questionCount = questionService.count(new QueryWrapper<Question>().eq("author_id", uid)); int questionCount = questionService.count(new QueryWrapper<Question>().eq("author_id", uid));
int commentCount = commentService.count(new QueryWrapper<Comment>().eq("user_id", uid)); int commentCount = commentService.count(new QueryWrapper<Comment>().eq("user_id", uid));

View File

@@ -32,13 +32,13 @@ public class Blog implements Serializable {
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Integer id; private Integer id;
@ApiModelProperty(value = "博客id") @ApiModelProperty(value = "论坛id")
private String bid; private String bid;
@ApiModelProperty(value = "博客标题") @ApiModelProperty(value = "论坛标题")
private String title; private String title;
@ApiModelProperty(value = "博客内容") @ApiModelProperty(value = "论坛内容")
private String content; private String content;
@ApiModelProperty(value = "排序 0 普通 1 置顶") @ApiModelProperty(value = "排序 0 普通 1 置顶")

View File

@@ -31,7 +31,7 @@ public class BlogCategory implements Serializable {
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Integer id; private Integer id;
@ApiModelProperty(value = "博客分类") @ApiModelProperty(value = "论坛分类")
private String category; private String category;

View File

@@ -35,7 +35,7 @@ public class Comment implements Serializable {
@ApiModelProperty(value = "评论唯一id") @ApiModelProperty(value = "评论唯一id")
private String commentId; private String commentId;
@ApiModelProperty(value = "1博客 2问答") @ApiModelProperty(value = "1论坛 2问答")
private Integer topicCategory; private Integer topicCategory;
@ApiModelProperty(value = "评论主题id") @ApiModelProperty(value = "评论主题id")

View File

@@ -31,7 +31,7 @@ public class SourceCategory implements Serializable {
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Integer id; private Integer id;
@ApiModelProperty(value = "博客分类") @ApiModelProperty(value = "论坛分类")
private String category; private String category;

View File

@@ -35,7 +35,7 @@ public class SourceComment implements Serializable {
@ApiModelProperty(value = "评论唯一id") @ApiModelProperty(value = "评论唯一id")
private String commentId; private String commentId;
@ApiModelProperty(value = "1博客 2问答") @ApiModelProperty(value = "1论坛 2问答")
private Integer topicCategory; private Integer topicCategory;
@ApiModelProperty(value = "评论主题id") @ApiModelProperty(value = "评论主题id")

View File

@@ -17,6 +17,19 @@ import java.io.OutputStream;
*/ */
public interface SourceService extends IService<Source> { public interface SourceService extends IService<Source> {
/**
* 下载对应的资源
* @param outputStream
* @param source
* @throws IOException
*/
void downloadSource(ServletOutputStream outputStream, Source source) throws IOException; void downloadSource(ServletOutputStream outputStream, Source source) throws IOException;
/**
* 点击对应的资源
* @throws IOException
* @return
*/
Source hotResource(String sid);
} }

View File

@@ -1,5 +1,7 @@
package com.quinn.service.impl; package com.quinn.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quinn.common.QuinnConstant;
import com.quinn.pojo.Source; import com.quinn.pojo.Source;
import com.quinn.mapper.SourceMapper; import com.quinn.mapper.SourceMapper;
import com.quinn.service.SourceService; import com.quinn.service.SourceService;
@@ -7,6 +9,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.quinn.utils.OSSClientUtil; import com.quinn.utils.OSSClientUtil;
import com.quinn.utils.RedisUtils; import com.quinn.utils.RedisUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
@@ -51,19 +54,26 @@ public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> impleme
} }
} }
@Override
public Source hotResource(String sid) {
Source source = getOne(new QueryWrapper<Source>().eq("id", sid));
addDownLoadRecord(source);
return source;
}
/** /**
* 更新页码 * 更新页码
* @param source * @param source
*/ */
private void addDownLoadRecord(Source source) { private void addDownLoadRecord(Source source) {
// Integer downLoadTime = (Integer) redisUtils.get(QuinnConstant.SOURCE_KEY + source.getId()); String downLoadTime = redisUtils.get(QuinnConstant.SOURCE_KEY + source.getId());
// int downTimes = 0; int downTimes = 0;
// if (StringUtils.isEmpty(downLoadTime)){ if (StringUtils.isEmpty(downLoadTime)){
// downTimes = source.getDownRecord() + 1; downTimes = source.getDownRecord() + 1;
// }else { }else {
// downTimes = downLoadTime + 1; downTimes = Integer.parseInt(downLoadTime) + 1;
// } }
// redisUtils.set(QuinnConstant.SOURCE_KEY + source.getId(),downTimes); redisUtils.set(QuinnConstant.SOURCE_KEY + source.getId(),downTimes + "");
source.setDownRecord(source.getDownRecord() + 1); source.setDownRecord(source.getDownRecord() + 1);
updateById(source); updateById(source);
} }

View File

@@ -1,5 +1,6 @@
package com.quinn.task; package com.quinn.task;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quinn.common.QuinnConstant; import com.quinn.common.QuinnConstant;
import com.quinn.pojo.Source; import com.quinn.pojo.Source;
import com.quinn.service.SourceService; import com.quinn.service.SourceService;
@@ -16,7 +17,7 @@ import java.util.List;
* *
* @author limqsh * @author limqsh
*/ */
//@Component @Component
public class UpdateViewTask { public class UpdateViewTask {
@Resource @Resource
@@ -28,18 +29,24 @@ public class UpdateViewTask {
/** /**
* 每小时执行一次 * 每小时执行一次
*/ */
// @Scheduled(cron = "0 0 */1 * * ?") @Scheduled(cron = "0 0 */1 * * ?")
public void execute(){ public void execute(){
List<Source> list = sourceService.list(null); List<String> keys = redisUtils.scan(QuinnConstant.SOURCE_KEY);
if (!CollectionUtils.isEmpty(list)){ // List<Source> list = sourceService.list(null);
list.forEach(x->{ if (!CollectionUtils.isEmpty(keys)){
String downTimes = (String) redisUtils.get(QuinnConstant.SOURCE_KEY + x.getId()); keys.forEach(x->{
if (!StringUtils.isEmpty(downTimes)){ Source source = sourceService.getById(getIdFromKey(x,QuinnConstant.SOURCE_KEY));
x.setDownRecord(Integer.parseInt(downTimes)); if (source != null && !StringUtils.isEmpty(source.getSourceName())){
sourceService.updateById(x); source.setDownRecord(Integer.parseInt(redisUtils.get(x)));
sourceService.updateById(source);
redisUtils.del(x);
} }
}); });
} }
} }
private String getIdFromKey(String key,String keyType){
return key.substring(keyType.length());
}
} }

View File

@@ -19,7 +19,6 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.*; import org.springframework.data.redis.core.*;
@@ -34,9 +33,9 @@ import java.util.concurrent.TimeUnit;
@Component @Component
public class RedisUtils { public class RedisUtils {
private static final Logger log = LoggerFactory.getLogger(RedisUtils.class); private static final Logger log = LoggerFactory.getLogger(RedisUtils.class);
private RedisTemplate<Object, Object> redisTemplate; private StringRedisTemplate redisTemplate;
public RedisUtils(RedisTemplate<Object, Object> redisTemplate) { public RedisUtils(StringRedisTemplate redisTemplate) {
this.redisTemplate = redisTemplate; this.redisTemplate = redisTemplate;
} }
@@ -83,7 +82,7 @@ public class RedisUtils {
* @param key 键 不能为null * @param key 键 不能为null
* @return 时间(秒) 返回0代表为永久有效 * @return 时间(秒) 返回0代表为永久有效
*/ */
public long getExpire(Object key) { public long getExpire(String key) {
return redisTemplate.getExpire(key, TimeUnit.SECONDS); return redisTemplate.getExpire(key, TimeUnit.SECONDS);
} }
@@ -96,7 +95,7 @@ public class RedisUtils {
public List<String> scan(String pattern) { public List<String> scan(String pattern) {
ScanOptions options = ScanOptions.scanOptions().match(pattern).build(); ScanOptions options = ScanOptions.scanOptions().match(pattern).build();
RedisConnectionFactory factory = redisTemplate.getConnectionFactory(); RedisConnectionFactory factory = redisTemplate.getConnectionFactory();
RedisConnection rc = Objects.requireNonNull(factory).getConnection(); RedisConnection rc = factory.getConnection();
Cursor<byte[]> cursor = rc.scan(options); Cursor<byte[]> cursor = rc.scan(options);
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
while (cursor.hasNext()) { while (cursor.hasNext()) {
@@ -121,7 +120,7 @@ public class RedisUtils {
public List<String> findKeysForPage(String patternKey, int page, int size) { public List<String> findKeysForPage(String patternKey, int page, int size) {
ScanOptions options = ScanOptions.scanOptions().match(patternKey).build(); ScanOptions options = ScanOptions.scanOptions().match(patternKey).build();
RedisConnectionFactory factory = redisTemplate.getConnectionFactory(); RedisConnectionFactory factory = redisTemplate.getConnectionFactory();
RedisConnection rc = Objects.requireNonNull(factory).getConnection(); RedisConnection rc = factory.getConnection();
Cursor<byte[]> cursor = rc.scan(options); Cursor<byte[]> cursor = rc.scan(options);
List<String> result = new ArrayList<>(size); List<String> result = new ArrayList<>(size);
int tmpIndex = 0; int tmpIndex = 0;
@@ -176,7 +175,7 @@ public class RedisUtils {
log.debug(new StringBuilder("删除缓存:").append(keys[0]).append(",结果:").append(result).toString()); log.debug(new StringBuilder("删除缓存:").append(keys[0]).append(",结果:").append(result).toString());
log.debug("--------------------------------------------"); log.debug("--------------------------------------------");
} else { } else {
Set<Object> keySet = new HashSet<>(); Set<String> keySet = new HashSet<>();
for (String key : keys) { for (String key : keys) {
keySet.addAll(redisTemplate.keys(key)); keySet.addAll(redisTemplate.keys(key));
} }
@@ -197,7 +196,7 @@ public class RedisUtils {
* @param key 键 * @param key 键
* @return 值 * @return 值
*/ */
public Object get(String key) { public String get(String key) {
return key == null ? null : redisTemplate.opsForValue().get(key); return key == null ? null : redisTemplate.opsForValue().get(key);
} }
@@ -207,7 +206,7 @@ public class RedisUtils {
* @param keys * @param keys
* @return * @return
*/ */
public List<Object> multiGet(List<String> keys) { public List<String> multiGet(List<String> keys) {
List list = redisTemplate.opsForValue().multiGet(Sets.newHashSet(keys)); List list = redisTemplate.opsForValue().multiGet(Sets.newHashSet(keys));
List resultList = Lists.newArrayList(); List resultList = Lists.newArrayList();
Optional.ofNullable(list).ifPresent(e-> list.forEach(ele-> Optional.ofNullable(ele).ifPresent(resultList::add))); Optional.ofNullable(list).ifPresent(e-> list.forEach(ele-> Optional.ofNullable(ele).ifPresent(resultList::add)));
@@ -221,7 +220,7 @@ public class RedisUtils {
* @param value 值 * @param value 值
* @return true成功 false失败 * @return true成功 false失败
*/ */
public boolean set(String key, Object value) { public boolean set(String key, String value) {
try { try {
redisTemplate.opsForValue().set(key, value); redisTemplate.opsForValue().set(key, value);
return true; return true;
@@ -239,7 +238,7 @@ public class RedisUtils {
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
* @return true成功 false 失败 * @return true成功 false 失败
*/ */
public boolean set(String key, Object value, long time) { public boolean set(String key, String value, long time) {
try { try {
if (time > 0) { if (time > 0) {
redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
@@ -262,7 +261,7 @@ public class RedisUtils {
* @param timeUnit 类型 * @param timeUnit 类型
* @return true成功 false 失败 * @return true成功 false 失败
*/ */
public boolean set(String key, Object value, long time, TimeUnit timeUnit) { public boolean set(String key, String value, long time, TimeUnit timeUnit) {
try { try {
if (time > 0) { if (time > 0) {
redisTemplate.opsForValue().set(key, value, time, timeUnit); redisTemplate.opsForValue().set(key, value, time, timeUnit);
@@ -307,7 +306,7 @@ public class RedisUtils {
* @param map 对应多个键值 * @param map 对应多个键值
* @return true 成功 false 失败 * @return true 成功 false 失败
*/ */
public boolean hmset(String key, Map<String, Object> map) { public boolean hmset(String key, Map<String, String> map) {
try { try {
redisTemplate.opsForHash().putAll(key, map); redisTemplate.opsForHash().putAll(key, map);
return true; return true;
@@ -325,7 +324,7 @@ public class RedisUtils {
* @param time 时间(秒) * @param time 时间(秒)
* @return true成功 false失败 * @return true成功 false失败
*/ */
public boolean hmset(String key, Map<String, Object> map, long time) { public boolean hmset(String key, Map<String, String> map, long time) {
try { try {
redisTemplate.opsForHash().putAll(key, map); redisTemplate.opsForHash().putAll(key, map);
if (time > 0) { if (time > 0) {
@@ -346,7 +345,7 @@ public class RedisUtils {
* @param value 值 * @param value 值
* @return true 成功 false失败 * @return true 成功 false失败
*/ */
public boolean hset(String key, String item, Object value) { public boolean hset(String key, String item, String value) {
try { try {
redisTemplate.opsForHash().put(key, item, value); redisTemplate.opsForHash().put(key, item, value);
return true; return true;
@@ -365,7 +364,7 @@ public class RedisUtils {
* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
* @return true 成功 false失败 * @return true 成功 false失败
*/ */
public boolean hset(String key, String item, Object value, long time) { public boolean hset(String key, String item, String value, long time) {
try { try {
redisTemplate.opsForHash().put(key, item, value); redisTemplate.opsForHash().put(key, item, value);
if (time > 0) { if (time > 0) {
@@ -384,7 +383,7 @@ public class RedisUtils {
* @param key 键 不能为null * @param key 键 不能为null
* @param item 项 可以使多个 不能为null * @param item 项 可以使多个 不能为null
*/ */
public void hdel(String key, Object... item) { public void hdel(String key, String... item) {
redisTemplate.opsForHash().delete(key, item); redisTemplate.opsForHash().delete(key, item);
} }
@@ -431,7 +430,7 @@ public class RedisUtils {
* @param key 键 * @param key 键
* @return * @return
*/ */
public Set<Object> sGet(String key) { public Set<String> sGet(String key) {
try { try {
return redisTemplate.opsForSet().members(key); return redisTemplate.opsForSet().members(key);
} catch (Exception e) { } catch (Exception e) {
@@ -447,7 +446,7 @@ public class RedisUtils {
* @param value 值 * @param value 值
* @return true 存在 false不存在 * @return true 存在 false不存在
*/ */
public boolean sHasKey(String key, Object value) { public boolean sHasKey(String key, String value) {
try { try {
return redisTemplate.opsForSet().isMember(key, value); return redisTemplate.opsForSet().isMember(key, value);
} catch (Exception e) { } catch (Exception e) {
@@ -463,7 +462,7 @@ public class RedisUtils {
* @param values 值 可以是多个 * @param values 值 可以是多个
* @return 成功个数 * @return 成功个数
*/ */
public long sSet(String key, Object... values) { public long sSet(String key, String... values) {
try { try {
return redisTemplate.opsForSet().add(key, values); return redisTemplate.opsForSet().add(key, values);
} catch (Exception e) { } catch (Exception e) {
@@ -480,7 +479,7 @@ public class RedisUtils {
* @param values 值 可以是多个 * @param values 值 可以是多个
* @return 成功个数 * @return 成功个数
*/ */
public long sSetAndTime(String key, long time, Object... values) { public long sSetAndTime(String key, long time, String... values) {
try { try {
Long count = redisTemplate.opsForSet().add(key, values); Long count = redisTemplate.opsForSet().add(key, values);
if (time > 0) { if (time > 0) {
@@ -515,7 +514,7 @@ public class RedisUtils {
* @param values 值 可以是多个 * @param values 值 可以是多个
* @return 移除的个数 * @return 移除的个数
*/ */
public long setRemove(String key, Object... values) { public long setRemove(String key, String... values) {
try { try {
Long count = redisTemplate.opsForSet().remove(key, values); Long count = redisTemplate.opsForSet().remove(key, values);
return count; return count;
@@ -535,7 +534,7 @@ public class RedisUtils {
* @param end 结束 0 到 -1代表所有值 * @param end 结束 0 到 -1代表所有值
* @return * @return
*/ */
public List<Object> lGet(String key, long start, long end) { public List<String> lGet(String key, long start, long end) {
try { try {
return redisTemplate.opsForList().range(key, start, end); return redisTemplate.opsForList().range(key, start, end);
} catch (Exception e) { } catch (Exception e) {
@@ -566,7 +565,7 @@ public class RedisUtils {
* @param index 索引 index>=0时 0 表头1 第二个元素依次类推index<0时-1表尾-2倒数第二个元素依次类推 * @param index 索引 index>=0时 0 表头1 第二个元素依次类推index<0时-1表尾-2倒数第二个元素依次类推
* @return * @return
*/ */
public Object lGetIndex(String key, long index) { public String lGetIndex(String key, long index) {
try { try {
return redisTemplate.opsForList().index(key, index); return redisTemplate.opsForList().index(key, index);
} catch (Exception e) { } catch (Exception e) {
@@ -582,7 +581,7 @@ public class RedisUtils {
* @param value 值 * @param value 值
* @return * @return
*/ */
public boolean lSet(String key, Object value) { public boolean lSet(String key, String value) {
try { try {
redisTemplate.opsForList().rightPush(key, value); redisTemplate.opsForList().rightPush(key, value);
return true; return true;
@@ -600,7 +599,7 @@ public class RedisUtils {
* @param time 时间(秒) * @param time 时间(秒)
* @return * @return
*/ */
public boolean lSet(String key, Object value, long time) { public boolean lSet(String key, String value, long time) {
try { try {
redisTemplate.opsForList().rightPush(key, value); redisTemplate.opsForList().rightPush(key, value);
if (time > 0) { if (time > 0) {
@@ -620,7 +619,7 @@ public class RedisUtils {
* @param value 值 * @param value 值
* @return * @return
*/ */
public boolean lSet(String key, List<Object> value) { public boolean lSet(String key, List<String> value) {
try { try {
redisTemplate.opsForList().rightPushAll(key, value); redisTemplate.opsForList().rightPushAll(key, value);
return true; return true;
@@ -638,7 +637,7 @@ public class RedisUtils {
* @param time 时间(秒) * @param time 时间(秒)
* @return * @return
*/ */
public boolean lSet(String key, List<Object> value, long time) { public boolean lSet(String key, List<String> value, long time) {
try { try {
redisTemplate.opsForList().rightPushAll(key, value); redisTemplate.opsForList().rightPushAll(key, value);
if (time > 0) { if (time > 0) {
@@ -659,7 +658,7 @@ public class RedisUtils {
* @param value 值 * @param value 值
* @return / * @return /
*/ */
public boolean lUpdateIndex(String key, long index, Object value) { public boolean lUpdateIndex(String key, long index, String value) {
try { try {
redisTemplate.opsForList().set(key, index, value); redisTemplate.opsForList().set(key, index, value);
return true; return true;
@@ -677,7 +676,7 @@ public class RedisUtils {
* @param value 值 * @param value 值
* @return 移除的个数 * @return 移除的个数
*/ */
public long lRemove(String key, long count, Object value) { public long lRemove(String key, long count, String value) {
try { try {
return redisTemplate.opsForList().remove(key, count, value); return redisTemplate.opsForList().remove(key, count, value);
} catch (Exception e) { } catch (Exception e) {
@@ -691,7 +690,7 @@ public class RedisUtils {
* @param ids id * @param ids id
*/ */
public void delByKeys(String prefix, Set<Long> ids) { public void delByKeys(String prefix, Set<Long> ids) {
Set<Object> keys = new HashSet<>(); Set<String> keys = new HashSet<>();
for (Long id : ids) { for (Long id : ids) {
keys.addAll(redisTemplate.keys(new StringBuffer(prefix).append(id).toString())); keys.addAll(redisTemplate.keys(new StringBuffer(prefix).append(id).toString()));
} }
@@ -702,4 +701,5 @@ public class RedisUtils {
log.debug("缓存删除数量:" + count + ""); log.debug("缓存删除数量:" + count + "");
log.debug("--------------------------------------------"); log.debug("--------------------------------------------");
} }
} }

View File

@@ -13,7 +13,7 @@ spring.redis.host=127.0.0.1
#Redis服务器连接端口 #Redis服务器连接端口
spring.redis.port=6379 spring.redis.port=6379
#Redis数据库索引默认为0 #Redis数据库索引默认为0
spring.redis.database=0 spring.redis.database=3
#Redis数据库密码 #Redis数据库密码
spring.redis.password= spring.redis.password=
#连接池最大连接数(使用负值表示没有限制) #连接池最大连接数(使用负值表示没有限制)

View File

@@ -46,7 +46,7 @@ try {
}, },
"referrer_hostname": { "referrer_hostname": {
"example.com": ["示例网站"], "example.com": ["示例网站"],
"www.fghrsh.net": ["FGHRSH 的博客"] "www.fghrsh.net": ["FGHRSH 的论坛"]
}, },
"model_message": { "model_message": {
"1": ["来自 Potion Maker 的 Pio 酱 ~"], "1": ["来自 Potion Maker 的 Pio 酱 ~"],
@@ -130,7 +130,7 @@ try {
live2d_settings['modelStorage'] = false; live2d_settings['modelStorage'] = false;
live2d_settings['canTurnToAboutPage'] = false; live2d_settings['canTurnToAboutPage'] = false;
live2d_settings['screenshotCaptureName']= 'quinn.png'; live2d_settings['screenshotCaptureName']= 'quinn.png';
live2d_settings['waifuEdgeSide'] = 'left:0'; // 看板娘贴边方向,例如 'left:0'(靠左 0px), 'right:30'(靠右 30px) live2d_settings['waifuEdgeSide'] = 'right:88'; // 看板娘贴边方向,例如 'left:0'(靠左 0px), 'right:30'(靠右 30px)
live2d_settings['waifuDraggable'] = 'unlimited'; // 拖拽样式,例如 'disable'(禁用), 'axis-x'(只能水平拖拽), 'unlimited'(自由拖拽) live2d_settings['waifuDraggable'] = 'unlimited'; // 拖拽样式,例如 'disable'(禁用), 'axis-x'(只能水平拖拽), 'unlimited'(自由拖拽)
live2d_settings['waifuDraggableRevert'] = true; // 松开鼠标还原拖拽位置,可选 true(真), false(假) live2d_settings['waifuDraggableRevert'] = true; // 松开鼠标还原拖拽位置,可选 true(真), false(假)
initModel(modelJson); initModel(modelJson);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -3,9 +3,9 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>博客-Quinn</title> <title>论坛-Quinn</title>
<link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}"> <link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}">
<link rel="stylesheet" th:href="@{/editormd/css/editormd.css}"/> <link rel="stylesheet" th:href="@{/wangedit/css/wang.style.css}"/>
<style> <style>
.nav-underline .nav-link { .nav-underline .nav-link {
@@ -25,7 +25,7 @@
<div class="row"> <div class="row">
<div class="col-md-12 blog-main"> <div class="col-md-12 blog-main">
<div class="col-md-12 order-md-1"> <div class="col-md-12 order-md-1">
<h4 class="mb-3">编辑博客</h4> <h4 class="mb-3">编辑论坛</h4>
<form class="needs-validation" th:action="@{/blog/editor}" method="post"> <form class="needs-validation" th:action="@{/blog/editor}" method="post">
<!-- 隐藏域 --> <!-- 隐藏域 -->
@@ -33,7 +33,7 @@
<div class="row"> <div class="row">
<div class="col-md-10 mb-3"> <div class="col-md-10 mb-3">
<label for="firstName">博客标题</label> <label for="firstName">论坛标题</label>
<input required th:value="${blog.getTitle()}" name="title" type="text" class="form-control" id="firstName"> <input required th:value="${blog.getTitle()}" name="title" type="text" class="form-control" id="firstName">
</div> </div>
@@ -48,9 +48,11 @@
</div> </div>
<div class="col-md-12 mb-3"> <div class="col-md-12 mb-3">
<p>博客详情</p> <p>论坛详情</p>
<div id="blog-content"> <div id="blog-content">
<textarea required name="content" th:text="${blog.getContent()}" id="content" style="display:none;" rows="3" class="form-control"> </textarea> <div id="editor-toolbar"></div>
<div id="editor-text-area" style="height: 400px;border: 1px solid lightgrey"></div>
<textarea id="blog-textarea" name="content" th:text="${blog.getContent()}" style="display: none;"></textarea>
</div> </div>
</div> </div>
@@ -71,50 +73,59 @@
<script th:src="@{/js/toTop.js}"></script> <script th:src="@{/js/toTop.js}"></script>
<script th:src="@{/js/jquery-ui.min.js}"></script> <script th:src="@{/js/jquery-ui.min.js}"></script>
<script th:src="@{/live/js/addlive2d.js}"></script> <script th:src="@{/live/js/addlive2d.js}"></script>
<script th:src="@{/editormd/editormd.js}"></script>
<script type="text/javascript">
var testEditor;
$(function() {
testEditor = editormd("blog-content", {
width : "100%",
height : 500,
syncScrolling : "single",
path : "/editormd/lib/",
saveHTMLToTextarea : true, // 保存 HTML 到 Textarea
// [TOCM] [TOC] 自动生成目录
tocDropdown : false,
tocStartLevel : 1, // Parse beginning of H2, Default value 1
emoji: true,
tex : true, // 开启科学公式TeX语言支持默认关闭
flowChart : true, // 开启流程图支持,默认关闭
sequenceDiagram : true, // 开启时序/序列图支持,默认关闭,
//图片上传
imageUpload : true,
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
imageUploadURL : "/question/write/file/upload",
onload : function() {
console.log('onload', this);
},
/*指定需要显示的功能按钮*/
toolbarIcons : function() {
return ["undo","redo","|",
"bold","del","italic","quote","ucwords","uppercase","lowercase","|",
"list-ul","list-ol","hr","|",
"link","reference-link","image",
"code-block","table","datetime","emoji","html-entities","|",
"search","watch","preview","fullscreen"]
},
onfullscreen : function() {
console.log("onfullscreen");
document.getElementsByClassName("navbar")[0].style.display="none";
},
onfullscreenExit : function() {
console.log("onfullscreenExit");
document.getElementsByClassName("navbar")[0].style.display="";
}
});
});
</script>
<script th:src="@{/wangedit/js/wang.min.js}"></script>
<script type="text/javascript">
const E = window.wangEditor
// 切换语言
const LANG = location.href.indexOf('lang=en') > 0 ? 'en' : 'zh-CN'
E.i18nChangeLanguage(LANG)
const editorConfig = {
placeholder: '请输入...',
scroll: true, // 禁止编辑器滚动
MENU_CONF: {
uploadImage: {
fieldName: 'your-fileName',
base64LimitSize: 10 * 1024 * 1024 // 10M 以下插入 base64
}
},
onChange(editor) {
// console.log(editor.getHtml())
// $('#blog-textarea').value = editor.getHtml()
const content = editor.children
// const contentStr = JSON.stringify(content)
// document.getElementById('blog-textarea').value = contentStr
const html = editor.getHtml()
$('#blog-textarea').val(html)
}
}
// 先创建 editor
const editor = E.createEditor({
selector: '#editor-text-area',
// content: [],
html: $('#blog-textarea').val(),
config: editorConfig
})
// 创建 toolbar
const toolbar = E.createToolbar({
editor,
selector: '#editor-toolbar',
config: {
excludeKeys: 'fullScreen',
}
})
// 点击空白处 focus 编辑器
$('#editor-text-area').addEventListener('click', e => {
if (e.target.id === 'editor-text-area') {
editor.blur()
editor.focus(true) // focus 到末尾
}
})
</script>
</body> </body>
</html> </html>

View File

@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>问答-Quinn</title> <title>论坛-Quinn</title>
<link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}"> <link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}">
</head> </head>
@@ -85,7 +85,7 @@
</div> </div>
<div class="p-4 my-3 bg-white rounded"> <div class="p-4 my-3 bg-white rounded">
<p class="mb-0"> 社区公约: <br> 禁止瞎水博客,内容尽量有实际意义,禁止任何形式的广告,违者暂停账号使用! 申请分类可以在Q群@小狂神 </p> <p class="mb-0"> 社区公约: <br> 禁止瞎水论坛,内容尽量有实际意义,禁止任何形式的广告,违者暂停账号使用! 申请分类可以在Q群@小狂神 </p>
</div> </div>
<div class="p-4 my-3 bg-white rounded"> <div class="p-4 my-3 bg-white rounded">

View File

@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>问答-Quinn</title> <title>论坛-Quinn</title>
<link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}"> <link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}">
<style> <style>

View File

@@ -3,9 +3,9 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>问答-Quinn</title> <title>论坛-Quinn</title>
<link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}"> <link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}">
<link rel="stylesheet" th:href="@{/editormd/css/editormd.css}"/> <link rel="stylesheet" th:href="@{/wangedit/css/wang.style.css}"/>
<style> <style>
.nav-underline .nav-link { .nav-underline .nav-link {
@@ -51,7 +51,9 @@
<div class="col-md-12 mb-3"> <div class="col-md-12 mb-3">
<p>文章内容</p> <p>文章内容</p>
<div id="blog-content"> <div id="blog-content">
<textarea required name="content" id="content" style="display:none;" rows="3" class="form-control"> </textarea> <div id="editor-toolbar"></div>
<div id="editor-text-area" style="height: 400px;border: 1px solid lightgrey"></div>
<textarea id="blog-textarea" name="content" style="display: none;"></textarea>
</div> </div>
</div> </div>
@@ -73,51 +75,58 @@
<script th:src="@{/js/jquery-ui.min.js}"></script> <script th:src="@{/js/jquery-ui.min.js}"></script>
<script th:src="@{/live/js/addlive2d.js}"></script> <script th:src="@{/live/js/addlive2d.js}"></script>
<script th:src="@{/editormd/editormd.js}"></script> <script th:src="@{/wangedit/js/wang.min.js}"></script>
<script type="text/javascript"> <script type="text/javascript">
var testEditor; const E = window.wangEditor
$(function() {
testEditor = editormd("blog-content", { // 切换语言
width : "100%", const LANG = location.href.indexOf('lang=en') > 0 ? 'en' : 'zh-CN'
height : 500, E.i18nChangeLanguage(LANG)
syncScrolling : "single",
path : "/editormd/lib/", const editorConfig = {
saveHTMLToTextarea : true, // 保存 HTML 到 Textarea placeholder: '请输入...',
// [TOCM] [TOC] 自动生成目录 scroll: true, // 禁止编辑器滚动
tocm : true, MENU_CONF: {
tocContainer : "", uploadImage: {
tocDropdown : false, fieldName: 'your-fileName',
tocStartLevel : 1, // Parse beginning of H2, Default value 1 base64LimitSize: 10 * 1024 * 1024 // 10M 以下插入 base64
emoji: true,
tex : true, // 开启科学公式TeX语言支持默认关闭
flowChart : true, // 开启流程图支持,默认关闭
sequenceDiagram : true, // 开启时序/序列图支持,默认关闭,
//图片上传
imageUpload : true,
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
imageUploadURL : "/question/write/file/upload",
onload : function() {
console.log('onload', this);
},
/*指定需要显示的功能按钮*/
toolbarIcons : function() {
return ["undo","redo","|",
"bold","del","italic","quote","ucwords","uppercase","lowercase","|",
"list-ul","list-ol","hr","|",
"link","reference-link","image",
"code-block","table","datetime","emoji","html-entities","|",
"search","watch","preview","fullscreen"]
},
onfullscreen : function() {
console.log("onfullscreen");
document.getElementsByClassName("navbar")[0].style.display="none";
},
onfullscreenExit : function() {
console.log("onfullscreenExit");
document.getElementsByClassName("navbar")[0].style.display="";
} }
}); },
}); onChange(editor) {
// console.log(editor.getHtml())
// $('#blog-textarea').value = editor.getHtml()
const content = editor.children
// const contentStr = JSON.stringify(content)
// document.getElementById('blog-textarea').value = contentStr
const html = editor.getHtml()
$('#blog-textarea').val(html)
}
}
// 先创建 editor
const editor = E.createEditor({
selector: '#editor-text-area',
content: [],
// html: '',
config: editorConfig
})
// 创建 toolbar
const toolbar = E.createToolbar({
editor,
selector: '#editor-toolbar',
config: {
excludeKeys: 'fullScreen',
}
})
// 点击空白处 focus 编辑器
$('#editor-text-area').addEventListener('click', e => {
if (e.target.id === 'editor-text-area') {
editor.blur()
editor.focus(true) // focus 到末尾
}
})
</script> </script>
</body> </body>

View File

@@ -24,7 +24,7 @@
<a class="nav-link" th:href="@{/question}">问答 </a> <a class="nav-link" th:href="@{/question}">问答 </a>
</li> </li>
<li th:class="${activeUrl=='blog'?'nav-item active':'nav-item'}"> <li th:class="${activeUrl=='blog'?'nav-item active':'nav-item'}">
<a class="nav-link" th:href="@{/blog}">博客 </a> <a class="nav-link" th:href="@{/blog}">论坛 </a>
</li> </li>
<li th:class="${activeUrl=='hotspot'?'nav-item active':'nav-item'}"> <li th:class="${activeUrl=='hotspot'?'nav-item active':'nav-item'}">
<a class="nav-link" th:href="@{/hotspot}">热门资源 </a> <a class="nav-link" th:href="@{/hotspot}">热门资源 </a>

View File

@@ -51,7 +51,7 @@
<table class="table"> <table class="table">
<thead id="table-title"> <thead id="table-title">
<tr> <tr>
<th scope="col">博客</th> <th scope="col">论坛</th>
<th scope="col">问题</th> <th scope="col">问题</th>
<th scope="col">回复</th> <th scope="col">回复</th>
</tr> </tr>
@@ -83,7 +83,7 @@
<path fill-rule="evenodd" d="M1.92.506a.5.5 0 0 1 .434.14L3 1.293l.646-.647a.5.5 0 0 1 .708 0L5 1.293l.646-.647a.5.5 0 0 1 .708 0L7 1.293l.646-.647a.5.5 0 0 1 .708 0L9 1.293l.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .801.13l.5 1A.5.5 0 0 1 15 2v13h-1V2.118l-.137-.274-.51.51a.5.5 0 0 1-.707 0L12 1.707l-.646.647a.5.5 0 0 1-.708 0L10 1.707l-.646.647a.5.5 0 0 1-.708 0L8 1.707l-.646.647a.5.5 0 0 1-.708 0L6 1.707l-.646.647a.5.5 0 0 1-.708 0L4 1.707l-.646.647a.5.5 0 0 1-.708 0l-.509-.51L2 2.118V15H1V2a.5.5 0 0 1 .053-.224l.5-1a.5.5 0 0 1 .367-.27zM0 15.5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1H.5a.5.5 0 0 1-.5-.5z"/> <path fill-rule="evenodd" d="M1.92.506a.5.5 0 0 1 .434.14L3 1.293l.646-.647a.5.5 0 0 1 .708 0L5 1.293l.646-.647a.5.5 0 0 1 .708 0L7 1.293l.646-.647a.5.5 0 0 1 .708 0L9 1.293l.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .801.13l.5 1A.5.5 0 0 1 15 2v13h-1V2.118l-.137-.274-.51.51a.5.5 0 0 1-.707 0L12 1.707l-.646.647a.5.5 0 0 1-.708 0L10 1.707l-.646.647a.5.5 0 0 1-.708 0L8 1.707l-.646.647a.5.5 0 0 1-.708 0L6 1.707l-.646.647a.5.5 0 0 1-.708 0L4 1.707l-.646.647a.5.5 0 0 1-.708 0l-.509-.51L2 2.118V15H1V2a.5.5 0 0 1 .053-.224l.5-1a.5.5 0 0 1 .367-.27zM0 15.5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1H.5a.5.5 0 0 1-.5-.5z"/>
<path fill-rule="evenodd" d="M3 4.5a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm8-8a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5z"/> <path fill-rule="evenodd" d="M3 4.5a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm8-8a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5z"/>
</svg> </svg>
博客 论坛
</a> </a>
<a class="nav-link" <a class="nav-link"
th:href="@{'/user/question/'+${session.loginUser.getUid()}+'/1/10'}"> th:href="@{'/user/question/'+${session.loginUser.getUid()}+'/1/10'}">

View File

@@ -39,7 +39,7 @@
<path fill-rule="evenodd" d="M1.92.506a.5.5 0 0 1 .434.14L3 1.293l.646-.647a.5.5 0 0 1 .708 0L5 1.293l.646-.647a.5.5 0 0 1 .708 0L7 1.293l.646-.647a.5.5 0 0 1 .708 0L9 1.293l.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .801.13l.5 1A.5.5 0 0 1 15 2v13h-1V2.118l-.137-.274-.51.51a.5.5 0 0 1-.707 0L12 1.707l-.646.647a.5.5 0 0 1-.708 0L10 1.707l-.646.647a.5.5 0 0 1-.708 0L8 1.707l-.646.647a.5.5 0 0 1-.708 0L6 1.707l-.646.647a.5.5 0 0 1-.708 0L4 1.707l-.646.647a.5.5 0 0 1-.708 0l-.509-.51L2 2.118V15H1V2a.5.5 0 0 1 .053-.224l.5-1a.5.5 0 0 1 .367-.27zM0 15.5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1H.5a.5.5 0 0 1-.5-.5z"/> <path fill-rule="evenodd" d="M1.92.506a.5.5 0 0 1 .434.14L3 1.293l.646-.647a.5.5 0 0 1 .708 0L5 1.293l.646-.647a.5.5 0 0 1 .708 0L7 1.293l.646-.647a.5.5 0 0 1 .708 0L9 1.293l.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .801.13l.5 1A.5.5 0 0 1 15 2v13h-1V2.118l-.137-.274-.51.51a.5.5 0 0 1-.707 0L12 1.707l-.646.647a.5.5 0 0 1-.708 0L10 1.707l-.646.647a.5.5 0 0 1-.708 0L8 1.707l-.646.647a.5.5 0 0 1-.708 0L6 1.707l-.646.647a.5.5 0 0 1-.708 0L4 1.707l-.646.647a.5.5 0 0 1-.708 0l-.509-.51L2 2.118V15H1V2a.5.5 0 0 1 .053-.224l.5-1a.5.5 0 0 1 .367-.27zM0 15.5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1H.5a.5.5 0 0 1-.5-.5z"/>
<path fill-rule="evenodd" d="M3 4.5a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm8-8a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5z"/> <path fill-rule="evenodd" d="M3 4.5a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm8-8a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5z"/>
</svg> </svg>
博客 论坛
</a> </a>
<a class="nav-link" <a class="nav-link"
th:href="@{'/user/question/'+${session.loginUser.getUid()}+'/1/10'}"> th:href="@{'/user/question/'+${session.loginUser.getUid()}+'/1/10'}">
@@ -69,7 +69,7 @@
class="text-dark font-weight-bold text-decoration-none d-block"> class="text-dark font-weight-bold text-decoration-none d-block">
</a> </a>
<!-- 类型 --> <!-- 类型 -->
<span th:text="${comment.getTopicCategory()==1?'博客':'问答'}" <span th:text="${comment.getTopicCategory()==1?'论坛':'问答'}"
th:class="${comment.getTopicCategory()==1?'badge badge-success':'badge badge-primary'}"> th:class="${comment.getTopicCategory()==1?'badge badge-success':'badge badge-primary'}">
</span> </span>
<!-- 时间 --> <!-- 时间 -->

View File

@@ -33,7 +33,7 @@
<path fill-rule="evenodd" d="M1.92.506a.5.5 0 0 1 .434.14L3 1.293l.646-.647a.5.5 0 0 1 .708 0L5 1.293l.646-.647a.5.5 0 0 1 .708 0L7 1.293l.646-.647a.5.5 0 0 1 .708 0L9 1.293l.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .801.13l.5 1A.5.5 0 0 1 15 2v13h-1V2.118l-.137-.274-.51.51a.5.5 0 0 1-.707 0L12 1.707l-.646.647a.5.5 0 0 1-.708 0L10 1.707l-.646.647a.5.5 0 0 1-.708 0L8 1.707l-.646.647a.5.5 0 0 1-.708 0L6 1.707l-.646.647a.5.5 0 0 1-.708 0L4 1.707l-.646.647a.5.5 0 0 1-.708 0l-.509-.51L2 2.118V15H1V2a.5.5 0 0 1 .053-.224l.5-1a.5.5 0 0 1 .367-.27zM0 15.5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1H.5a.5.5 0 0 1-.5-.5z"/> <path fill-rule="evenodd" d="M1.92.506a.5.5 0 0 1 .434.14L3 1.293l.646-.647a.5.5 0 0 1 .708 0L5 1.293l.646-.647a.5.5 0 0 1 .708 0L7 1.293l.646-.647a.5.5 0 0 1 .708 0L9 1.293l.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .708 0l.646.647.646-.647a.5.5 0 0 1 .801.13l.5 1A.5.5 0 0 1 15 2v13h-1V2.118l-.137-.274-.51.51a.5.5 0 0 1-.707 0L12 1.707l-.646.647a.5.5 0 0 1-.708 0L10 1.707l-.646.647a.5.5 0 0 1-.708 0L8 1.707l-.646.647a.5.5 0 0 1-.708 0L6 1.707l-.646.647a.5.5 0 0 1-.708 0L4 1.707l-.646.647a.5.5 0 0 1-.708 0l-.509-.51L2 2.118V15H1V2a.5.5 0 0 1 .053-.224l.5-1a.5.5 0 0 1 .367-.27zM0 15.5a.5.5 0 0 1 .5-.5h15a.5.5 0 0 1 0 1H.5a.5.5 0 0 1-.5-.5z"/>
<path fill-rule="evenodd" d="M3 4.5a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm8-8a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5z"/> <path fill-rule="evenodd" d="M3 4.5a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5zm8-8a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 0 1h-1a.5.5 0 0 1-.5-.5z"/>
</svg> </svg>
博客 论坛
</a> </a>
<a class="nav-link active" <a class="nav-link active"
th:href="@{'/user/question/'+${session.loginUser.getUid()}+'/1/10'}"> th:href="@{'/user/question/'+${session.loginUser.getUid()}+'/1/10'}">

View File

@@ -0,0 +1,54 @@
package com.quinn.test;
import com.quinn.QuinnApplication;
import com.quinn.common.QuinnConstant;
import com.quinn.pojo.Source;
import com.quinn.service.SourceService;
import com.quinn.utils.RedisUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(classes={QuinnApplication.class})
public class RedisTest {
@Resource
SourceService sourceService;
@Resource
RedisUtils redisUtils;
@Test
public void updateViewTask(){
List<String> keys = redisUtils.scan(QuinnConstant.SOURCE_KEY + QuinnConstant.REDIS_PATTEN);
if (!CollectionUtils.isEmpty(keys)){
keys.forEach(x->{
Source source = sourceService.getById(getIdFromKey(x,QuinnConstant.SOURCE_KEY));
if (source != null && !StringUtils.isEmpty(source.getSourceName())){
source.setDownRecord(Integer.parseInt(redisUtils.get(x)));
sourceService.updateById(source);
redisUtils.del(x);
}
});
}
}
@Test
public void setTestKey(){
redisUtils.set(QuinnConstant.SOURCE_KEY+1,"123");
redisUtils.set(QuinnConstant.SOURCE_KEY+2,"456");
redisUtils.set(QuinnConstant.SOURCE_KEY+3,"789");
}
private String getIdFromKey(String key,String keyType){
return key.substring(keyType.length());
}
}