优化博客
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
16
src/main/java/com/quinn/common/RoleType.java
Normal file
16
src/main/java/com/quinn/common/RoleType.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.quinn.common;
|
||||
|
||||
public enum RoleType {
|
||||
/**
|
||||
* 管理员
|
||||
*/
|
||||
ADMIN,
|
||||
/**
|
||||
* 普通用户
|
||||
*/
|
||||
NORMAL,
|
||||
/**
|
||||
* VIP
|
||||
*/
|
||||
VIP
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
// 写文章
|
||||
|
||||
@@ -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()));
|
||||
|
||||
// 注册成功,重定向到登录页面
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
27
src/main/java/com/quinn/pojo/SourceWithStar.java
Normal file
27
src/main/java/com/quinn/pojo/SourceWithStar.java
Normal 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;
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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> {
|
||||
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,9 @@ public class MyPageParam {
|
||||
@ApiModelProperty(value = "总量")
|
||||
private int total;
|
||||
|
||||
@ApiModelProperty(value = "总量")
|
||||
private int allTotal;
|
||||
|
||||
public boolean hasPrevious(){
|
||||
return current > 1;
|
||||
}
|
||||
|
||||
19
src/main/java/com/quinn/vo/NavReq.java
Normal file
19
src/main/java/com/quinn/vo/NavReq.java
Normal 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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
16
src/main/java/com/quinn/vo/QuerySourcePage.java
Normal file
16
src/main/java/com/quinn/vo/QuerySourcePage.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.quinn.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QuerySourcePage extends QuerySource{
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
private int pageNum;
|
||||
/**
|
||||
* 每页数量
|
||||
*/
|
||||
private int limit;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user