优化博客

This commit is contained in:
limqhz
2022-05-10 02:21:30 +08:00
parent 1826e4bb9a
commit b0b9e80f8a
28 changed files with 339 additions and 227 deletions

View File

@@ -27,5 +27,5 @@ public interface QuinnConstant {
String EDIT_SOURCE_FIRST = "lw@";
String EDIT_SOURCE_LAST = "#";
String DEFAULT_ATTR_BASE64 = "/attrIcon";
String DEFAULT_ATTR_BASE64 = "/images/avatar/quinn.png";
}

View File

@@ -0,0 +1,16 @@
package com.quinn.common;
public enum RoleType {
/**
* 管理员
*/
ADMIN,
/**
* 普通用户
*/
NORMAL,
/**
* VIP
*/
VIP
}

View File

@@ -3,14 +3,19 @@ package com.quinn.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.quinn.common.RoleType;
import com.quinn.pojo.About;
import com.quinn.pojo.User;
import com.quinn.service.AboutService;
import com.quinn.service.UserService;
import com.quinn.utils.QuinnUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.management.relation.Role;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
@@ -22,10 +27,12 @@ import java.util.List;
* @since 2022-05-01
*/
@Controller
public class AboutController {
public class AboutController extends BaseModelController {
@Resource
AboutService aboutService;
@Resource
UserService userService;
@GetMapping("/about")
@@ -40,10 +47,12 @@ public class AboutController {
return "page/about";
}
@PostMapping("/about/{role}")
public String saveSay(@PathVariable("role") int role, About about){
@PostMapping("/about")
public String saveSay(HttpServletRequest request, About about){
String loginUserId = getLoginUserId(request);
User user = userService.getOne(new QueryWrapper<User>().eq("uid", ""));
// 防止请求提交
if (role!=1){
if (!RoleType.ADMIN.name().equals(user)){
return "redirect:/about";
}
about.setId(QuinnUtils.getUuid());

View File

@@ -6,10 +6,7 @@ import com.quinn.common.Category;
import com.quinn.pojo.*;
import com.quinn.service.*;
import com.quinn.utils.QuinnUtils;
import com.quinn.vo.StarReq;
import com.quinn.vo.MyPageParam;
import com.quinn.vo.QuestionWriteForm;
import com.quinn.vo.StarValue;
import com.quinn.vo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -51,7 +48,7 @@ public class BlogController extends BaseModelController{
List<BlogWithUser> blogList = blogService.getBlogWithUserOrderBySort(myPageParam);
// 结果
model.addAttribute("blogList",blogList);
model.addAttribute("myPageParam",myPageParam);
model.addAttribute("pageParam",myPageParam);
List<Blog> topBlogList = blogService.getTopBlog();
model.addAttribute("topBlogList",topBlogList);
@@ -63,20 +60,17 @@ public class BlogController extends BaseModelController{
return "blog/list";
}
@GetMapping("/blog/{page}/{limit}")
public String blogListPage(
@PathVariable int page,
@PathVariable int limit,
Model model){
if (page < 1){
page = 1;
@PostMapping("/blog")
public String blogListPage(NavReq navReq, Model model){
// 用户的论坛列表
if (navReq.getPageNum() < 1){
navReq.setPageNum(1);
}
MyPageParam myPageParam = new MyPageParam(page,limit);
MyPageParam myPageParam = new MyPageParam(navReq.getPageNum(),navReq.getLimit());
List<BlogWithUser> blogList = blogService.getBlogWithUserOrderBySort(myPageParam);
// 结果
model.addAttribute("blogList",blogList);
model.addAttribute("myPageParam",myPageParam);
model.addAttribute("pageParam",myPageParam);
List<Blog> topBlogList = blogService.getTopBlog();
model.addAttribute("topBlogList",topBlogList);
@@ -85,7 +79,7 @@ public class BlogController extends BaseModelController{
List<BlogCategory> categoryList = blogCategoryService.list(null);
model.addAttribute("categoryList",categoryList);
return "blog/list";
return "blog/list::s_table_refresh";
}
// 写文章

View File

@@ -1,6 +1,7 @@
package com.quinn.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quinn.common.RoleType;
import com.quinn.pojo.Invite;
import com.quinn.pojo.User;
import com.quinn.pojo.UserInfo;
@@ -78,7 +79,7 @@ public class LoginController {
// 构建用户对象
User user = new User();
user.setUid(QuinnUtils.getUuid()); // 用户唯一id
user.setRoleId(2);
user.setRoleId(RoleType.NORMAL.name());
user.setUsername(registerForm.getUsername());
// 密码加密
String bCryptPassword = new BCryptPasswordEncoder().encode(registerForm.getPassword());
@@ -93,7 +94,6 @@ public class LoginController {
invite.setUid(user.getUid());
inviteService.updateById(invite);
// todo: 用户信息
userInfoService.save(new UserInfo().setUid(user.getUid()));
// 注册成功,重定向到登录页面

View File

@@ -7,13 +7,11 @@ import com.quinn.common.Category;
import com.quinn.common.QuinnConstant;
import com.quinn.common.SourceType;
import com.quinn.pojo.*;
import com.quinn.pojo.param.QuerySource;
import com.quinn.service.CommentService;
import com.quinn.service.SourceCategoryService;
import com.quinn.service.SourceService;
import com.quinn.service.StarService;
import com.quinn.vo.StarReq;
import com.quinn.vo.StarValue;
import com.quinn.vo.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.CollectionUtils;
@@ -52,23 +50,12 @@ public class SourceController extends BaseModelController {
// 列表展示
@GetMapping("/source")
public String sourceList(Model model){
Page<Source> pageParam = new Page<>(1, 10);
QueryWrapper<Source> sourceQuery = new QueryWrapper<>();
sourceQuery.orderByDesc("gmt_create");
sourceService.page(pageParam,sourceQuery);
QuerySource querySource = new QuerySource();
MyPageParam myPageParam = new MyPageParam(1,10);
List<SourceWithStar> sourceList = sourceService.listPageStar(querySource,myPageParam);
// 结果
List<Source> sourceList = pageParam.getRecords();
if (!CollectionUtils.isEmpty(sourceList)){
sourceList.forEach(x ->{
x.setSourceLink(QuinnConstant.GUN);
x.setKeyWord1(QuinnConstant.GUN);
x.setKeyWord2(QuinnConstant.GUN);
x.setKeyWord3(QuinnConstant.GUN);
x.setSourceContent(QuinnConstant.GUN);
});
}
model.addAttribute("sourceList",sourceList);
model.addAttribute("pageParam",pageParam);
model.addAttribute("pageParam",myPageParam);
// 分类信息
List<SourceCategory> categoryList = sourceCategoryService.list(null);
@@ -77,23 +64,19 @@ public class SourceController extends BaseModelController {
return "source/list";
}
@PostMapping("/source/page")
public String blogListPage(QuerySource querySource, Model model){
@PostMapping("/source")
public String blogListPage(QuerySourcePage querySource, Model model){
int page = querySource.getPageNum();
int limit = querySource.getLimit();
if (querySource.getPageNum() < 1){
page = 1;
}
Page<Source> pageParam = new Page<>(page, limit);
QueryWrapper<Source> sourceQuery = new QueryWrapper<>();
addParam(sourceQuery,querySource.getName(),querySource.getCategory());
sourceQuery.orderByDesc("gmt_create");
sourceService.page(pageParam,sourceQuery);
MyPageParam myPageParam = new MyPageParam(page,limit);
List<SourceWithStar> sourceList = sourceService.listPageStar(querySource,myPageParam);
// 结果
List<Source> blogList = pageParam.getRecords();
model.addAttribute("sourceList",blogList);
model.addAttribute("pageParam",pageParam);
model.addAttribute("sourceList",sourceList);
model.addAttribute("pageParam",myPageParam);
return "source/list::s_table_refresh";
}
@@ -174,13 +157,4 @@ public class SourceController extends BaseModelController {
}
}
private void addParam(QueryWrapper<Source> sourceQuery, String name, int category) {
if (!StringUtils.isEmpty(name)){
sourceQuery.like("source_name",name);
}
if (category > 0){
sourceQuery.eq("category_id",category);
}
}
}

View File

@@ -28,7 +28,7 @@ public class StarController extends BaseModelController {
StarService starService;
// 取消收藏
@GetMapping("/user/comment/delete/{starId}")
@GetMapping("/user/star/delete/{starId}")
public String deleteComment(HttpServletRequest request, @PathVariable String starId){
String loginUserId = getLoginUserId(request);
Star star = starService.getById(starId);

View File

@@ -12,6 +12,15 @@ public enum AttrIcon {
INSTANCE;
/**
* 用户名
* @param name
*/
public String generateImgUrl(String name) {
String attrUrl = "https://api.multiavatar.com/";
return attrUrl + name + ".png";
}
/**
* 用户名
* @param name

View File

@@ -2,6 +2,11 @@ package com.quinn.mapper;
import com.quinn.pojo.Source;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.quinn.pojo.SourceWithStar;
import com.quinn.vo.MyPageParam;
import com.quinn.vo.QuerySource;
import java.util.List;
/**
* <p>
@@ -13,4 +18,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface SourceMapper extends BaseMapper<Source> {
List<SourceWithStar> listPageStar(QuerySource querySource, MyPageParam myPageParam);
}

View File

@@ -2,4 +2,20 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.quinn.mapper.SourceMapper">
<select id="listPageStar" resultType="com.quinn.pojo.SourceWithStar">
select id,sid,source_name,detail,source_type,category_id,category_name,en_name,file_type,down_record,gmt_create,gmt_update,
(select count(1) from qn_star c where c.topic_id = sid and c.topic_category = 'SOURCE') as star
from qn_source
<where>
<if test="querySource.name!=null and querySource.name != ''">
and source_name like CONCAT('%',#{querySource.name},'%')
</if>
<if test="querySource.category > 0">
and category_id = #{querySource.category}
</if>
</where>
order by gmt_create desc
limit #{myPageParam.pageNum},#{myPageParam.size}
</select>
</mapper>

View File

@@ -71,7 +71,7 @@ public class Source implements Serializable {
private String fileType;
@ApiModelProperty(value = "下载次数")
private Integer downRecord;
private int downRecord;
@ApiModelProperty(value = "创建时间")
private Date gmtCreate;

View File

@@ -0,0 +1,27 @@
package com.quinn.pojo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author limqsh
* @since 2022-05-03
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SourceWithStar extends Source implements Serializable {
@ApiModelProperty(value = "收藏")
private int star;
}

View File

@@ -36,7 +36,7 @@ public class User implements Serializable {
private String uid;
@ApiModelProperty(value = "角色编号")
private Integer roleId;
private String roleId;
@ApiModelProperty(value = "用户名")
private String username;

View File

@@ -2,6 +2,9 @@ package com.quinn.service;
import com.quinn.pojo.Source;
import com.baomidou.mybatisplus.extension.service.IService;
import com.quinn.pojo.SourceWithStar;
import com.quinn.vo.MyPageParam;
import com.quinn.vo.QuerySource;
import com.quinn.vo.SourceUpdateForm;
import com.quinn.vo.SourceWriteForm;
import org.springframework.web.multipart.MultipartFile;
@@ -10,6 +13,7 @@ import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
/**
* <p>
@@ -57,4 +61,6 @@ public interface SourceService extends IService<Source> {
* @param sid
*/
void deleteSource(String sid);
List<SourceWithStar> listPageStar(QuerySource querySource, MyPageParam myPageParam);
}

View File

@@ -1,16 +0,0 @@
package com.quinn.service;
import com.quinn.pojo.UserRole;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author limqsh
* @since 2020-06-28
*/
public interface UserRoleService extends IService<UserRole> {
}

View File

@@ -7,11 +7,14 @@ import com.quinn.mapper.SourceCategoryMapper;
import com.quinn.pojo.Source;
import com.quinn.mapper.SourceMapper;
import com.quinn.pojo.SourceCategory;
import com.quinn.pojo.SourceWithStar;
import com.quinn.service.SourceService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.quinn.utils.OSSClientUtil;
import com.quinn.utils.QuinnUtils;
import com.quinn.utils.RedisUtils;
import com.quinn.vo.MyPageParam;
import com.quinn.vo.QuerySource;
import com.quinn.vo.SourceUpdateForm;
import com.quinn.vo.SourceWriteForm;
import org.springframework.stereotype.Service;
@@ -25,6 +28,7 @@ import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.List;
/**
* <p>
@@ -43,6 +47,8 @@ public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> impleme
RedisUtils redisUtils;
@Resource
SourceCategoryMapper sourceCategoryMapper;
@Resource
SourceMapper sourceMapper;
@Override
public void downloadSource(HttpServletResponse response, Source source) throws IOException {
@@ -182,6 +188,27 @@ public class SourceServiceImpl extends ServiceImpl<SourceMapper, Source> impleme
removeById(before);
}
@Override
public List<SourceWithStar> listPageStar(QuerySource querySource, MyPageParam myPageParam) {
QueryWrapper<Source> sourceQuery = new QueryWrapper<>();
int allCount = count(sourceQuery);
myPageParam.setAllTotal(allCount);
addParam(sourceQuery,querySource.getName(),querySource.getCategory());
int count = count(sourceQuery);
myPageParam.setTotal(count);
return sourceMapper.listPageStar(querySource,myPageParam);
}
private void addParam(QueryWrapper<Source> sourceQuery, String name, int category) {
if (!StringUtils.isEmpty(name)){
sourceQuery.like("source_name",name);
}
if (category > 0){
sourceQuery.eq("category_id",category);
}
}
/**
* 更新页码
* @param source

View File

@@ -1,20 +0,0 @@
package com.quinn.service.impl;
import com.quinn.pojo.UserRole;
import com.quinn.mapper.UserRoleMapper;
import com.quinn.service.UserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author limqsh
* @since 2020-06-28
*/
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements UserRoleService {
}

View File

@@ -1,10 +1,10 @@
package com.quinn.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.quinn.common.QuinnConstant;
import com.quinn.common.RoleType;
import com.quinn.pojo.User;
import com.quinn.mapper.UserMapper;
import com.quinn.pojo.UserRole;
import com.quinn.service.UserRoleService;
import com.quinn.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
@@ -17,7 +17,7 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Arrays;
import java.util.List;
/**
@@ -37,8 +37,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
@Autowired
UserService userService;
@Autowired
UserRoleService roleService;
@Autowired
HttpSession session;
// 用户登录逻辑和验证处理
@@ -47,9 +45,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
// 通过用户名查询用户
User user = userService.getOne(new QueryWrapper<User>().eq("username", s));
// 放入session
session.setAttribute("loginUser",user);
//创建一个新的UserDetails对象最后验证登陆的需要
UserDetails userDetails=null;
if(user!=null){
@@ -57,26 +52,23 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
//String BCryptPassword = new BCryptPasswordEncoder().encode(user.getPassword());
// 登录后会将登录密码进行加密,然后比对数据库中的密码,数据库密码需要加密存储!
String password = user.getPassword();
user.setPassword(QuinnConstant.GUN);
// 放入session
session.setAttribute("loginUser",user);
//创建一个集合来存放权限
Collection<GrantedAuthority> authorities = getAuthorities(user);
List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>();
RoleType[] values = RoleType.values();
Arrays.stream(values).forEach(x->{
authList.add(new SimpleGrantedAuthority("ROLE_" + x.name()));
});
//实例化UserDetails对象
userDetails=new org.springframework.security.core.userdetails.User(s,password,
true,
true,
true,
true, authorities);
true, authList);
}
return userDetails;
}
// 获取角色信息
private Collection<GrantedAuthority> getAuthorities(User user){
List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>();
UserRole role = roleService.getById(user.getRoleId());
//注意这里每个权限前面都要加ROLE_。否在最后验证不会通过
authList.add(new SimpleGrantedAuthority("ROLE_"+role.getName()));
return authList;
}
}

View File

@@ -28,6 +28,9 @@ public class MyPageParam {
@ApiModelProperty(value = "总量")
private int total;
@ApiModelProperty(value = "总量")
private int allTotal;
public boolean hasPrevious(){
return current > 1;
}

View File

@@ -0,0 +1,19 @@
package com.quinn.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class NavReq {
@ApiModelProperty(value = "页码")
private int pageNum;
@ApiModelProperty(value = "个数")
private int limit;
}

View File

@@ -1,4 +1,4 @@
package com.quinn.pojo.param;
package com.quinn.vo;
import lombok.Data;
@@ -13,13 +13,5 @@ public class QuerySource {
* 资源类别
*/
private int category;
/**
* 页码
*/
private int pageNum;
/**
* 每页数量
*/
private int limit;
}

View File

@@ -0,0 +1,16 @@
package com.quinn.vo;
import lombok.Data;
@Data
public class QuerySourcePage extends QuerySource{
/**
* 页码
*/
private int pageNum;
/**
* 每页数量
*/
private int limit;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

View File

@@ -15,11 +15,11 @@
<div class="row">
<div class="col-md-9 blog-main">
<div class="my-3 p-3 bg-white rounded shadow-sm">
<div th:fragment="s_table_refresh" th:id="id_s_table_refresh">
<h6 class="border-bottom border-gray pb-2 mb-0">
论坛累计:
<span th:text="${myPageParam.getTotal()}"></span>
<span th:text="${pageParam.getTotal()}"></span>
</h6>
<!-- 时间 -->
<div th:each="blog:${blogList}" class="media pt-3 border-bottom border-gray">
<!-- 头像 -->
<img th:src="${blog.getAvatar()}" style="border-radius: 5px " width="32" height="32">
@@ -60,24 +60,24 @@
<!--分页-->
<nav aria-label="Page navigation example" class="mt-4">
<ul class="pagination justify-content-center pagination-sm">
<li th:class="${myPageParam.hasPrevious()==true?'page-item':'page-item disabled'}">
<a class="page-link" th:href="@{'/blog/'+${myPageParam.getCurrent()-1}+'/10'}" tabindex="">Previous</a>
<li th:class="${pageParam.hasPrevious()==true?'page-item':'page-item disabled'}">
<a class="page-link" href="javascript:navChange(-1);" tabindex="">Previous</a>
</li>
<li class="page-item" th:if="${myPageParam.hasPrevious()}">
<a class="page-link" th:href="@{'/blog/'+${myPageParam.getCurrent()-1}+'/10'}" th:text="${myPageParam.getCurrent()-1}"></a>
<li class="page-item" th:if="${pageParam.hasPrevious()}">
<a class="page-link" href="javascript:navChange(-1);" th:text="${pageParam.getCurrent()-1}"></a>
</li>
<li class="page-item active">
<a class="page-link" th:href="@{'/blog/'+${myPageParam.getCurrent()}+'/10'}" th:text="${myPageParam.getCurrent()}"></a>
<a id = "current" class="page-link" href="javascript:navChange(0);" th:text="${pageParam.getCurrent()}"></a>
</li>
<li class="page-item" th:if="${myPageParam.hasNext()}">
<a class="page-link" th:href="@{'/blog/'+${myPageParam.getCurrent()+1}+'/10'}" th:text="${myPageParam.getCurrent()+1}"></a>
<li class="page-item" th:if="${pageParam.hasNext()}">
<a class="page-link" href="javascript:navChange(1);" th:text="${pageParam.getCurrent()+1}"></a>
</li>
<li th:class="${myPageParam.hasNext()==true?'page-item':'page-item disabled'}">
<a class="page-link" th:href="@{'/blog/'+${myPageParam.getCurrent()+1}+'/10'}" >Next</a>
<li th:class="${pageParam.hasNext()==true?'page-item':'page-item disabled'}">
<a class="page-link" href="javascript:navChange(1);">Next</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
@@ -101,7 +101,6 @@
<br/>
<span>如果发的帖子水分过大,可能会被封禁账号,请酌情发帖评论!</span>
</div>
<div class="p-4 my-3 bg-white rounded">
<h4 class="pb-1">推荐</h4>
<ul class="list-unstyled small" th:each="topBlog:${topBlogList}">
@@ -131,10 +130,20 @@
<script th:src="@{/js/toTop.js}"></script>
<script th:src="@{/js/jquery-ui.min.js}"></script>
<script th:src="@{/live/js/addlive2d.js}"></script>
<script>
<script type="text/javascript">
function navChange(page){
var current = $('#current').text();
var pageNum = parseInt(current) + page;
$.ajax({
url: "/blog",
async: false,
type: "post",
data: {"pageNum": pageNum, "limit": 10},
success: function (data) {
$('#id_s_table_refresh').html(data);
}
});
}
</script>
</body>
</html>

View File

@@ -15,7 +15,7 @@
<main role="main">
<div class="container">
<div class="col-md-12 blog-main" style="margin-top: 20px">
<form th:action="@{'/about/'+${session.loginUser.getRoleId()}}" method="post">
<form th:action="@{'/about'}" method="post">
<div class="col-md-12 mb-3">
<label>标题</label>
<input type="text" name="title" class="form-control" value="" required>

View File

@@ -18,7 +18,7 @@
<input type="text" name="username" class="form-control mb-2" placeholder="用户名" required="">
<input type="password" name="password" class="form-control" placeholder="密码" required="">
<input type="password" name="repassword" class="form-control" placeholder="确认密码" required="">
<input type="text" name="code" class="form-control" placeholder="社区邀请码" required="">
<input type="text" name="code" class="form-control" placeholder="邀请码" required="">
<button class="btn btn-lg btn-primary btn-block mt-3" type="submit" onclick="this.disabled=true; this.form.submit();">注 册</button>

View File

@@ -5,70 +5,57 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>资源库-Quinn</title>
<link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}">
<link rel="stylesheet" th:href="@{/css/download.css}">
<style>
#maxLength {
max-width: 500px;
white-space: nowrap; /* 不换行 */
overflow: hidden; /* 超出部分不显示 */
text-overflow: ellipsis; /* 超出部分显示为... */
}
</style>
</head>
<body>
<div th:replace="~{common/header::header(activeUrl='source')}"></div>
<main role="main" class="mt-3">
<div class="container">
<form action="javascript:navChange(0);" method="post">
<div class="form-row align-items-center">
<div class="col-auto">
<label class="sr-only" for="name">KEYWORD</label>
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">关键字</div>
</div>
<input type="text" class="form-control" id="name" name="name" placeholder="请输入关键字"/>
<main role="main" class="container">
<div class="row">
<div class="col-md-9 blog-main">
<div class="my-3 p-3 bg-white rounded shadow-sm">
<h6 class="border-bottom border-gray pb-2 mb-0">
累计资源总量:
<span th:text="${pageParam.getAllTotal()}"></span>
</h6>
<div th:fragment="s_table_refresh" th:id="id_s_table_refresh">
<div th:each="source:${sourceList}" class="media pt-3 border-bottom border-gray">
<div class="media-body small pl-2">
<!-- 标题 -->
<a th:href="@{'/source/view/'+${source.getSid()}}"
class="text-dark font-weight-bold text-decoration-none">
<span th:if="${source.getDownRecord() > 20}" class="badge badge-danger"></span>
[[${source.getSourceName()}]]
</a>
<!-- 收藏 -->
<span class="badge badge-dark">
[[${source.getCategoryName()}]]
(
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" class="bi bi-heart-fill" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"/>
</svg>
[[${source.getStar()}]]
)
</span>
<p class="float-right" th:text="${#dates.format(source.getGmtUpdate(),'yyyy-MM-dd HH:mm:ss')}"></p>
<div class="small">
<span id="maxLength" th:text="${source.getDetail()}"
class="d-block">
</span>
</div>
</div>
<div class="col-auto">
<label class="sr-only" for="category">SOURCE-TYPE</label>
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">类别</div>
</div>
<select id="category" name="category" class="form-control custom-select">
<option th:value=-1 th:text="请选择"></option>
<option th:each="category:${categoryList}" th:value="${category.getId()}" th:text="${category.getCategory()}"></option>
</select>
</div>
</div>
<div class="col-auto ml-auto">
<button type="submit" class="btn btn-primary mb-2">查询</button>
</div>
</div>
</form>
</div>
<div class="container" th:fragment="s_table_refresh" th:id="id_s_table_refresh">
<table class="table">
<thead class="thead-light">
<tr>
<th scope="col">资源名</th>
<th scope="col">资源简介</th>
<th scope="col">资源类型</th>
<th scope="col">热度</th>
<th scope="col">去下载</th>
</tr>
</thead>
<tbody>
<tr th:each="source:${sourceList}">
<td th:text="${source.getSourceName()}"></td>
<td th:text="${source.getDetail()}"></td>
<td th:text="${source.getCategoryName()}"></td>
<td th:text="${source.getDownRecord()}"></td>
<td th:name="${source.getSid()}">
<a style="color: white" th:href="@{'/source/view/'+${source.getSid()}}" class="btn btn-sm btn-secondary">详情</a>
</td>
</tr>
</tbody>
</table>
<nav aria-label="Page navigation example">
<ul class="pagination justify-content-center">
<!--分页-->
<nav aria-label="Page navigation example" class="mt-4">
<ul class="pagination justify-content-center pagination-sm">
<li th:class="${pageParam.hasPrevious()==true?'page-item':'page-item disabled'}">
<a class="page-link" href="javascript:navChange(-1);" tabindex="">Previous</a>
</li>
@@ -87,6 +74,53 @@
</ul>
</nav>
</div>
</div>
</div>
<aside class="col-md-3 blog-sidebar">
<div class="p-1 my-2 bg-white rounded">
<strong class="mb-0">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bookmarks-fill" viewBox="0 0 16 16">
<path d="M2 4a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L7 13.101l-4.223 2.815A.5.5 0 0 1 2 15.5V4z"/>
<path d="M4.268 1A2 2 0 0 1 6 0h6a2 2 0 0 1 2 2v11.5a.5.5 0 0 1-.777.416L13 13.768V2a1 1 0 0 0-1-1H4.268z"/>
</svg>
敲黑板
</strong>
<br/>
<span>如果发的帖子水分过大,可能会被封禁账号,请酌情发帖评论!</span>
</div>
<div class="p-1 my-2 bg-white rounded">
<form action="javascript:navChange(0);" method="post">
<div class="form-row align-items-center">
<div class="col-md-12 form-control-sm">
<label class="sr-only" for="name">KEYWORD</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">名称</div>
</div>
<input type="text" class="form-control" id="name" name="name" placeholder="请输入关键字"/>
</div>
</div>
<div class="col-md-12 mt-3 form-control-sm">
<label class="sr-only" for="category">SOURCE-TYPE</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">类别</div>
</div>
<select id="category" name="category" class="form-control custom-select">
<option th:value=-1 th:text="请选择"></option>
<option th:each="category:${categoryList}" th:value="${category.getId()}" th:text="${category.getCategory()}"></option>
</select>
</div>
</div>
<div class="col-md-12 mt-3 form-control-sm">
<button type="submit" class="btn btn-primary btn-block">查询</button>
</div>
</div>
</form>
</div>
</aside>
</div>
</main>
<div th:replace="~{common/footer::footer}"></div>
@@ -104,7 +138,8 @@
var current = $('#current').text();
var pageNum = parseInt(current) + page;
$.ajax({
url: "/source/page",
url: "/source",
async: false,
type: "post",
data: {"name": name, "category": category, "pageNum": pageNum, "limit": 10},
success: function (data) {

View File

@@ -62,14 +62,12 @@
class="text-dark font-weight-bold text-decoration-none d-block">
</a>
<!-- 浏览量 -->
<span style="color: red">
<span class="badge badge-success">
<svg class="bi bi-eye-fill" width="1em" height="1em" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path d="M10.5 8a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z"/>
<path fill-rule="evenodd" d="M0 8s3-5.5 8-5.5S16 8 16 8s-3 5.5-8 5.5S0 8 0 8zm8 3.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z"/>
</svg>
[[${blog.getViews()}]]
</span>
<span style="color: red">
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="currentColor" class="bi bi-heart-fill" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 1.314C12.438-3.248 23.534 4.735 8 15-7.534 4.736 3.562-3.248 8 1.314z"/>
</svg>
@@ -139,9 +137,9 @@
<span th:text="${session.loginUser.getUsername()}"></span>
<br>
<small>
<!--<span class="badge badge-primary">普通用户</span>-->
<span th:class="${session.loginUser.getRoleId()==2?'badge badge-warning':'badge badge-success'}"
th:text="${session.loginUser.getRoleId()==2?'Vip会员':'管理员'}">
<span th:if="${session.loginUser.getRoleId()=='ADMIN'}" class="badge badge-primary">超级管理员</span>
<span th:if="${session.loginUser.getRoleId()!='ADMIN'}" th:class="${session.loginUser.getRoleId()=='VIP'?'badge badge-warning':'badge badge-success'}"
th:text="${session.loginUser.getRoleId()=='VIP'?'VIP会员':'普通用户'}">
</span>
</small>
<p>