修改博客

master
zhangmeng 2021-11-17 18:20:30 +08:00
parent 33be0d7c00
commit b40d043645
17 changed files with 355 additions and 105 deletions

View File

@ -8,12 +8,15 @@ import com.zhangmeng.admin.manager.service.*;
import com.zhangmeng.admin.manager.utils.UserUtil;
import com.zhangmeng.model.base.baseController.BaseController;
import com.zhangmeng.model.base.baseUtil.CommonUtil;
import com.zhangmeng.model.dto.article.ArticleDto;
import com.zhangmeng.model.dto.article.ArticleModel;
import com.zhangmeng.model.dto.system.EncryptType;
import com.zhangmeng.model.dto.system.Menu;
import com.zhangmeng.model.dto.query.QueryParams;
import com.zhangmeng.model.dto.system.SysConstant;
import com.zhangmeng.model.entity.*;
import com.zhangmeng.model.vo.Result;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
@ -30,8 +33,8 @@ import java.util.*;
/**
* @author zhangmeng
* @date 202111909:06:23
* @version 1.0
* @date 202111909:06:23
*/
@Controller
public class UrlRequestController extends BaseController {
@ -74,21 +77,21 @@ public class UrlRequestController extends BaseController {
//跳转首页
@GetMapping({"/login"})
public ModelAndView login (){
public ModelAndView login() {
return this.jumpPage("admin/login");
}
//首页
@PostMapping("/admin/index")
public ModelAndView admin_index(Model model){
public ModelAndView admin_index(Model model) {
String uuid = UUID.randomUUID().toString();
model.addAttribute("uuid",uuid);
model.addAttribute("uuid", uuid);
User user = this.userUtil.currentUser();
String photo = "/mystyle-cloud-admin-manager/system/admin/images/avatar.jpg";
if (user.getAvatar() == null ){
if (user.getAvatar() == null) {
user.setAvatar(photo);
}
model.addAttribute("loginUser",user);
model.addAttribute("loginUser", user);
return this.jumpPage("admin/index");
}
@ -112,71 +115,74 @@ public class UrlRequestController extends BaseController {
model.addAttribute("loginUser", loginUser);
//用户人数
Integer user_count = this.userService.selectCountEq("deleteStatus", false);
model.addAttribute("user_count",user_count);
model.addAttribute("user_count", user_count);
//文章数量
Integer article_count = this.articleFeign.selectCountEq( false);
model.addAttribute("article_count",article_count);
Integer article_count = this.articleFeign.selectCountEq(false);
model.addAttribute("article_count", article_count);
//小说数量
model.addAttribute("fiction_count",16);
model.addAttribute("fiction_count", 16);
//消息数量
model.addAttribute("message_count",200);
model.addAttribute("message_count", 200);
//最新的十篇文章
List<Article> articleList = this.articleFeign.findByCondition();
//折线图
List<String> X_date = CommonUtil.day_of_pass(7);//x
List<Integer> Y_data= this.articleFeign.selectCountByDayOfPass(X_date);
Map<String,Object> data_x_y = new HashMap<>();
List<Integer> Y_data = this.articleFeign.selectCountByDayOfPass(X_date);
Map<String, Object> data_x_y = new HashMap<>();
data_x_y.put("X_date", JSONObject.toJSONString(X_date));
data_x_y.put("Y_data",JSONObject.toJSONString(Y_data));
model.addAttribute("data_x_y",data_x_y);
model.addAttribute("articleList",articleList);
data_x_y.put("Y_data", JSONObject.toJSONString(Y_data));
model.addAttribute("data_x_y", data_x_y);
model.addAttribute("articleList", articleList);
//日志
List<SysLog> sysLogs = this.sysLogService.findAll(new QueryParams(1, 10, "addTime desc"));
List<Map<String,Object>> list = new ArrayList<>();
if (sysLogs.size()>0){
List<Map<String, Object>> list = new ArrayList<>();
if (sysLogs.size() > 0) {
for (SysLog sysLog : sysLogs) {
Map<String,Object> map = new HashMap<>();
Map<String, Object> map = new HashMap<>();
User user = this.userService.findById(sysLog.getUser_id());
map.put("avatar",user.getAvatar() == null ? "/mystyle-cloud-admin-manager/system/admin/images/avatar.jpg":user.getAvatar());
map.put("username",user.getUsername());
map.put("addTime",sysLog.getAddTime());
map.put("description",sysLog.getDescription());
map.put("avatar", user.getAvatar() == null ? "/mystyle-cloud-admin-manager/system/admin/images/avatar.jpg" : user.getAvatar());
map.put("username", user.getUsername());
map.put("addTime", sysLog.getAddTime());
map.put("description", sysLog.getDescription());
String date_difference = CommonUtil.date_difference(sysLog.getAddTime());
map.put("date_difference",date_difference);
map.put("date_difference", date_difference);
list.add(map);
}
}
model.addAttribute("sysLogs",list);
model.addAttribute("sysLogs", list);
return jumpPage("admin/home/home");
}
/**
*
*
* @param model
* @return
*/
@GetMapping("/user/index")
public ModelAndView user_index(Model model){
public ModelAndView user_index(Model model) {
return this.jumpPage("admin/user/list");
}
/**
*
*
* @param model
* @return
*/
@GetMapping("/user/add")
public ModelAndView user_add(Model model){
public ModelAndView user_add(Model model) {
return this.jumpPage("admin/user/add");
}
/**
*
*
* @param model
* @return
*/
@GetMapping("/user/edit")
public ModelAndView user_edit(Model model,String userId){
public ModelAndView user_edit(Model model, String userId) {
if (userId != null && !userId.equals("")) {
User user = this.userService.findById(Long.parseLong(userId));
model.addAttribute("user", user);
@ -186,6 +192,7 @@ public class UrlRequestController extends BaseController {
/**
*
*
* @return
*/
@GetMapping("/role/index")
@ -195,6 +202,7 @@ public class UrlRequestController extends BaseController {
/**
*
*
* @param model
* @return
*/
@ -216,6 +224,7 @@ public class UrlRequestController extends BaseController {
/**
*
*
* @param model
* @param roleId
* @return
@ -237,7 +246,7 @@ public class UrlRequestController extends BaseController {
@GetMapping("/permission/add")
public ModelAndView permission_add(Model model) {
model.addAttribute("permissionTypeList",Permission.Type.valueListMap());
model.addAttribute("permissionTypeList", Permission.Type.valueListMap());
return this.jumpPage("admin/permission/add");
}
@ -246,16 +255,16 @@ public class UrlRequestController extends BaseController {
if (CommonUtil.isNotNull(permissionId)) {
Permission permission = this.permissionService.findById(Long.parseLong(permissionId));
model.addAttribute("permission", permission);
model.addAttribute("permissionTypeList",Permission.Type.valueListMap());
model.addAttribute("permissionTypeList", Permission.Type.valueListMap());
}
return this.jumpPage("admin/permission/edit");
}
@GetMapping("/article/index")
public ModelAndView article_index(Model model,Long categoryId) {
public ModelAndView article_index(Model model, Long categoryId) {
List<Category> categoryList = this.categoryFeign.findAll();
model.addAttribute("categoryList",categoryList);
model.addAttribute("categoryId",categoryId == null ? 0L : categoryId);
model.addAttribute("categoryList", categoryList);
model.addAttribute("categoryId", categoryId == null ? 0L : categoryId);
return this.jumpPage("admin/article/list");
}
@ -268,10 +277,10 @@ public class UrlRequestController extends BaseController {
}
@GetMapping("/article/edit")
public ModelAndView article_edit(Model model,String articleId) {
if (CommonUtil.isNotNull(articleId)){
public ModelAndView article_edit(Model model, String articleId) {
if (CommonUtil.isNotNull(articleId)) {
Article article = this.articleFeign.findById(Long.parseLong(articleId));
model.addAttribute("article",article);
model.addAttribute("article", article);
//查询分类
List<Category> categoryList = this.categoryFeign.findAll();
model.addAttribute("categoryList", categoryList);
@ -280,64 +289,64 @@ public class UrlRequestController extends BaseController {
}
@GetMapping("/category/index")
public ModelAndView category_index(){
public ModelAndView category_index() {
return this.jumpPage("admin/category/list");
}
@GetMapping("/category/add")
public ModelAndView category_add(Model model){
public ModelAndView category_add(Model model) {
Category.Type[] values = Category.Type.values();
model.addAttribute("categoryTypeList",values);
model.addAttribute("categoryTypeList", values);
return this.jumpPage("admin/category/add");
}
@GetMapping("/category/edit")
public ModelAndView category_edit(Model model,String categoryId){
public ModelAndView category_edit(Model model, String categoryId) {
Category.Type[] values = Category.Type.values();
model.addAttribute("categoryTypeList",values);
model.addAttribute("categoryTypeList", values);
Category category = null;
if (categoryId != null && !categoryId.equals("")){
category = this.categoryFeign.findById(Long.parseLong(categoryId));
if (categoryId != null && !categoryId.equals("")) {
category = this.categoryFeign.findById(Long.parseLong(categoryId));
}
model.addAttribute("category",category);
model.addAttribute("category", category);
return this.jumpPage("admin/category/edit");
}
@GetMapping("/file/index")
public ModelAndView file_index(){
public ModelAndView file_index() {
return this.jumpPage("admin/file/list");
}
@GetMapping("/file/add")
public ModelAndView file_add(){
public ModelAndView file_add() {
return this.jumpPage("admin/file/add");
}
@GetMapping("/file/upload")
public ModelAndView file_upload(){
public ModelAndView file_upload() {
return this.jumpPage("admin/file/upload");
}
@GetMapping("/quartz/index")
public ModelAndView quartz_index(){
public ModelAndView quartz_index() {
return this.jumpPage("admin/job/job-list");
}
@GetMapping("/quartz/add")
public ModelAndView quartz_add(Model model){
public ModelAndView quartz_add(Model model) {
Set<String> names = this.quartzFeign.spring_bean_list();
model.addAttribute("spring_bean_list",names);
model.addAttribute("spring_bean_list", names);
return this.jumpPage("admin/job/job-add");
}
@GetMapping("/quartz/edit")
public ModelAndView quartz_edit(Model model,String jobId){
public ModelAndView quartz_edit(Model model, String jobId) {
Set<String> names = this.quartzFeign.spring_bean_list();
model.addAttribute("spring_bean_list",names);
if (CommonUtil.isNotNull(jobId)){
model.addAttribute("spring_bean_list", names);
if (CommonUtil.isNotNull(jobId)) {
QuartzJob job = this.quartzFeign.findById(Long.parseLong(jobId));
model.addAttribute("job",job);
model.addAttribute("job", job);
}
return this.jumpPage("admin/job/job-edit");
}
@ -345,12 +354,12 @@ public class UrlRequestController extends BaseController {
@GetMapping("/crypt/encrypt")
public ModelAndView index(Model model) {
EncryptType[] values = EncryptType.values();
model.addAttribute("encryptTypeList",values);
model.addAttribute("encryptTypeList", values);
return this.jumpPage("admin/code/encrypt");
}
@GetMapping("/admin/form/tools")
public ModelAndView form_gen(){
public ModelAndView form_gen() {
return this.jumpPage("admin/code/form");
}
@ -365,12 +374,12 @@ public class UrlRequestController extends BaseController {
}
@GetMapping(SysConstant.mail_prefix + "/edit")
public ModelAndView mail_edit(String mail_id,Model model) {
if (mail_id != null ){
Mail mail = this.mailFeign.findById(Long.parseLong(mail_id));
if (CommonUtil.isNotNull(mail)){
model.addAttribute("mail",mail);
}
public ModelAndView mail_edit(String mail_id, Model model) {
if (mail_id != null) {
Mail mail = this.mailFeign.findById(Long.parseLong(mail_id));
if (CommonUtil.isNotNull(mail)) {
model.addAttribute("mail", mail);
}
}
return this.jumpPage("admin/mail/edit");
}
@ -384,26 +393,26 @@ public class UrlRequestController extends BaseController {
public ModelAndView chapter(Model model, @PathVariable Long id) {
Fiction fiction = this.fictionFeign.findById(id);
model.addAttribute("fiction",fiction);
model.addAttribute("fiction", fiction);
List<FictionChapter> fictionChapterList = this.fictionFeign.findByFictionId(id);
model.addAttribute("fictionChapter",fictionChapterList.get(0));
model.addAttribute("fictionChapterList",fictionChapterList);
model.addAttribute("fictionChapter", fictionChapterList.get(0));
model.addAttribute("fictionChapterList", fictionChapterList);
return this.jumpPage("xiaoshuo/fiction_chapter");
}
@GetMapping(SysConstant.fiction_prefix + "/details/{chapter_id}")
public ModelAndView details(Model model, @PathVariable String chapter_id){
public ModelAndView details(Model model, @PathVariable String chapter_id) {
String replace = chapter_id.replace(",", "");
Long id = Long.parseLong(replace);
List<FictionDetails> fictionDetailsList = this.fictionFeign.fictionDetailsId(id);
if (fictionDetailsList.size() > 0){
if (fictionDetailsList.size() > 0) {
FictionDetails fictionDetails = fictionDetailsList.get(0);
String content = fictionDetails.getContent();
content = "<br>&nbsp;&nbsp;&nbsp;&nbsp;" + content;
String replace1 = content.replace(" ", "<br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;");
fictionDetails.setContent(replace1);
model.addAttribute("fictionDetails",fictionDetails);
model.addAttribute("fictionDetails", fictionDetails);
}
return this.jumpPage("xiaoshuo/fiction_details");
}
@ -439,9 +448,9 @@ public class UrlRequestController extends BaseController {
@GetMapping(SysConstant.fictionCollection_prefix + "/edit")
public ModelAndView fictionCollection_edit(@RequestParam("fiction_id") Long fiction_id,Model model){
public ModelAndView fictionCollection_edit(@RequestParam("fiction_id") Long fiction_id, Model model) {
FictionCollection fictionCollection = this.fictionFeign.findFictionCollectionById(fiction_id);
model.addAttribute("fictionCollection",fictionCollection);
model.addAttribute("fictionCollection", fictionCollection);
return this.jumpPage("admin/fiction/fiction_edit");
}
@ -469,13 +478,13 @@ public class UrlRequestController extends BaseController {
@RequestMapping("/zipkin")
public RedirectView zipkin_loginPage() {
String url = "http://localhost:9411/zipkin/";
String url = "http://localhost:9411/zipkin/";
return new RedirectView(url);
}
@RequestMapping("/sentinel")
public RedirectView nacos_loginPage() {
String url = "http://localhost:8748/#/login";
String url = "http://localhost:8748/#/login";
return new RedirectView(url);
}
@ -488,4 +497,25 @@ public class UrlRequestController extends BaseController {
String path = serviceInstance.getUri().toString();
return new RedirectView(path);
}
/**
*
*
* @param model
* @param pageNum
* @param pageSize
* @return
*/
@GetMapping("/blog/index")
public ModelAndView index(Model model, Integer pageNum, Integer pageSize) {
if (pageNum == null) {
pageNum = CommonUtil.pageNum;
}
if (pageSize == null) {
pageSize = CommonUtil.pageSize;
}
Map<String, Object> map = this.articleFeign.getListByPage(pageNum, pageSize);
model.addAllAttributes(map);
return this.jumpPage("blog/v1/index");
}
}

View File

@ -159,4 +159,10 @@ public class UserController extends BaseController implements UserControllerApi
public User findByUserName(String username) {
return this.userService.loadUserByUsername(username);
}
@Override
@GetMapping("findByUserId")
public User findByUserId(@RequestParam("userId") Long userId){
return this.userService.findById(userId);
}
}

View File

@ -1,5 +1,7 @@
package com.zhangmeng.admin.manager.feign;
import com.github.pagehelper.PageInfo;
import com.zhangmeng.model.dto.query.QueryParams;
import com.zhangmeng.model.dto.system.SysConstant;
import com.zhangmeng.model.entity.Article;
import org.springframework.cloud.openfeign.FeignClient;
@ -8,6 +10,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
import java.util.Map;
@FeignClient(value = SysConstant.mystyle_cloud_blog,contextId ="ArticleFeign")
public interface ArticleFeign {
@ -23,4 +26,7 @@ public interface ArticleFeign {
@GetMapping("/article/findById")
Article findById(@RequestParam(value = "articleId") Long articleId);
@GetMapping("/article/getListByPage")
Map<String,Object> getListByPage(@RequestParam("pageNum") Integer pageNum,@RequestParam("pageSize") Integer pageSize);
}

View File

@ -53,11 +53,9 @@ mapper:
enum-as-simple-type: true
identity: MYSQL
check-example-entity-class: true
mystyle:
security:
open-api:
- /
- /login
- /favicon.ico # 开放FAVICON
- /system/**
@ -73,6 +71,8 @@ mystyle:
- /webjars/**
- /actuator/**
- /instances/**
- /blog/index
- /user/findByUserId
verification-code:
type: mysql
expiration-time: 300

View File

@ -35,4 +35,7 @@ public interface UserControllerApi {
@ApiOperation("根据用户名称查询用户")
public User findByUserName(String username);
@ApiOperation("根据用户id查询用户")
public User findByUserId(@RequestParam("userId") Long userId);
}

View File

@ -1,5 +1,7 @@
package com.zhangmeng.api.service.blog;
import com.github.pagehelper.PageInfo;
import com.zhangmeng.model.dto.query.QueryParams;
import com.zhangmeng.model.entity.Article;
import com.zhangmeng.model.vo.Result;
import io.swagger.annotations.Api;
@ -35,4 +37,7 @@ public interface ArticleControllerApi {
@ApiOperation("根据id查询")
public Article findById(@RequestParam Long articleId);
@ApiOperation("查询文章")
Map<String,Object> getListByPage(@RequestParam Integer pageNum,@RequestParam Integer pageSize);
}

View File

@ -7,6 +7,8 @@ import com.zhangmeng.blog.service.ArticleService;
import com.zhangmeng.blog.service.CategoryService;
import com.zhangmeng.model.base.baseController.BaseController;
import com.zhangmeng.model.base.baseUtil.CommonUtil;
import com.zhangmeng.model.dto.article.ArticleDto;
import com.zhangmeng.model.dto.article.ArticleModel;
import com.zhangmeng.model.dto.query.QueryParams;
import com.zhangmeng.model.entity.Article;
import com.zhangmeng.model.entity.Category;
@ -15,6 +17,7 @@ import com.zhangmeng.model.vo.Result;
import com.zhangmeng.model.vo.StatusCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
@ -24,9 +27,7 @@ import tk.mybatis.mapper.entity.Condition;
import tk.mybatis.mapper.entity.Example;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
@RestController
@ -179,8 +180,40 @@ public class ArticleController extends BaseController implements ArticleControll
return this.articleService.findByCondition(new QueryParams(new Condition(Article.class)));
}
@Override
@GetMapping("/findById")
public Article findById(@RequestParam Long articleId){
return this.articleService.findById(articleId);
}
@Override
@GetMapping("/getListByPage")
public Map<String,Object> getListByPage(@RequestParam Integer pageNum,@RequestParam Integer pageSize){
Map<String,Object> map = new HashMap<>();
ArticleModel articleModel = new ArticleModel();
//文章总数
Condition article_condition = new Condition(Article.class);
Example.Criteria article_criteria = article_condition.createCriteria();
article_criteria.andEqualTo("deleteStatus", false);
//文章列表
PageInfo<Article> pageInfo = this.articleService.findByCondition(new QueryParams(pageNum, pageSize, article_condition, "addTime desc"), true);
articleModel.setPrePage(pageInfo.getPrePage());
articleModel.setNextPage(pageInfo.getNextPage());
articleModel.setPageNum(pageInfo.getPageNum());
articleModel.setPageSize(pageInfo.getPageSize());
List<ArticleDto> article_dto_list = new ArrayList<>();
if (pageInfo.getList().size() > 0) {
for (Article article : pageInfo.getList()) {
ArticleDto articleDto = new ArticleDto();
BeanUtils.copyProperties(article, articleDto);
Long user_id = article.getUser_id();
User user = this.userFeign.findByUserId(user_id);
articleDto.setAvatar(user.getAvatar());
article_dto_list.add(articleDto);
}
}
articleModel.setArticleDto_list(article_dto_list);
map.put("articleModel", articleModel);
return map;
}
}

View File

@ -4,10 +4,14 @@ import com.zhangmeng.model.dto.system.SysConstant;
import com.zhangmeng.model.entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(SysConstant.mystyle_cloud_admin_manager)
public interface UserFeign {
@GetMapping("/user/current")
public User getCurrentUser();
@GetMapping("/user/findByUserId")
public User findByUserId(@RequestParam("userId") Long userId);
}

View File

@ -58,6 +58,7 @@ mystyle:
- /webjars/**
- /actuator/**
- /instances/**
- /article/getListByPage
management:
endpoints:
web:
@ -69,5 +70,4 @@ management:
enabled: true
logging:
file:
name: ./logs/mystyle-cloud-blog.log
level: debug
name: ./logs/mystyle-cloud-blog.log

View File

@ -0,0 +1,79 @@
package com.zhangmeng.gateway.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @author
* @date 202191416:50:47
* @version 1.0
* */
@Configuration
@ConfigurationProperties("mystyle.security")
public class SecurityProperty {
/**
*
* */
private boolean superAuthOpen;
/**
*
* */
private String superAdmin;
/**
*
* */
private String rememberKey;
/**
*
* */
private String[] openApi;
/**
* 线
* */
private Integer maximum = 1;
public boolean isSuperAuthOpen() {
return superAuthOpen;
}
public void setSuperAuthOpen(boolean superAuthOpen) {
this.superAuthOpen = superAuthOpen;
}
public String getSuperAdmin() {
return superAdmin;
}
public void setSuperAdmin(String superAdmin) {
this.superAdmin = superAdmin;
}
public String getRememberKey() {
return rememberKey;
}
public void setRememberKey(String rememberKey) {
this.rememberKey = rememberKey;
}
public String[] getOpenApi() {
return openApi;
}
public void setOpenApi(String[] openApi) {
this.openApi = openApi;
}
public Integer getMaximum() {
return maximum;
}
public void setMaximum(Integer maximum) {
this.maximum = maximum;
}
}

View File

@ -4,9 +4,5 @@ package com.zhangmeng.gateway.feign;
*
*/
public class SysConstant {
public static final String mystyle_cloud_admin_manager = "mystyle-cloud-admin-manager";
public static final String mystyle_cloud_oauth = "mystyle-cloud-oauth";
}

View File

@ -1,5 +1,7 @@
package com.zhangmeng.gateway.filter;
import com.zhangmeng.gateway.config.SecurityProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
@ -29,6 +31,9 @@ public class AuthorizeFilter implements GlobalFilter, Ordered {
private static final String AUTHORIZE_TOKEN = "Authorization";
@Autowired
private SecurityProperty securityProperty;
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
@ -36,25 +41,15 @@ public class AuthorizeFilter implements GlobalFilter, Ordered {
ServerHttpRequest request = exchange.getRequest();
//2.获取响应对象
ServerHttpResponse response = exchange.getResponse();
//3.判断 是否为登录的URL 如果是 放行
if (request.getURI().getPath().startsWith("/mystyle-cloud-oauth/user/login")) {
return chain.filter(exchange);
//3.开发端口直接放行
String[] openApi = this.securityProperty.getOpenApi();
if (openApi.length > 0 ){
for (String url : openApi) {
if (request.getURI().getPath().startsWith(url)){
return chain.filter(exchange);
}
}
}
if (request.getURI().getPath().startsWith("/mystyle-cloud-admin-manager/login")) {
return chain.filter(exchange);
}
if (request.getURI().getPath().startsWith("/mystyle-cloud-admin-manager/system")) {
return chain.filter(exchange);
}
//mystyle-cloud-admin-manager/verificationCode/generate 验证码
if (request.getURI().getPath().startsWith("/mystyle-cloud-admin-manager/verificationCode/generate")) {
return chain.filter(exchange);
}
//4.判断 是否为登录的URL 如果不是 权限校验
//4.1 从头header中获取令牌数据
String token = request.getHeaders().getFirst(AUTHORIZE_TOKEN);
@ -97,10 +92,11 @@ public class AuthorizeFilter implements GlobalFilter, Ordered {
/**
*
*
* @param serverHttpRequest
* @return
*/
private String resolveBodyFromRequest(ServerHttpRequest serverHttpRequest){
private String resolveBodyFromRequest(ServerHttpRequest serverHttpRequest) {
//获取请求体
Flux<DataBuffer> body = serverHttpRequest.getBody();
StringBuilder sb = new StringBuilder();

View File

@ -84,6 +84,12 @@ spring:
- Path=/mystyle-cloud-admin-monitor/**
filters:
- StripPrefix=1
- id: mystyle-cloud-blog-web
uri: lb://mystyle-cloud-admin-manager
predicates:
- Path=/mystyle-cloud-web-blog/**
filters:
- StripPrefix=1
management:
endpoints:
web:
@ -95,4 +101,14 @@ management:
enabled: true
logging:
file:
name: ./logs/mystyle-cloud-gateway.log
name: ./logs/mystyle-cloud-gateway.log
#开放接口
mystyle:
security:
open-api:
- /mystyle-cloud-admin-manager/verificationCode/generate
- /mystyle-cloud-admin-manager/system
- /mystyle-cloud-admin-manager/login
- /mystyle-cloud-oauth/user/login
- /mystyle-cloud-web-blog/blog/index

View File

@ -97,9 +97,9 @@ public class CommonUtil {
private static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
private static Integer pageNum = 1;
public static Integer pageNum = 1;
private static Integer pageSize = 10;
public static Integer pageSize = 10;
private static String[] parsePatterns = {
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",

View File

@ -0,0 +1,16 @@
package com.zhangmeng.model.dto.article;
import com.zhangmeng.model.entity.Article;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
@EqualsAndHashCode(callSuper = true)
@Data
public class ArticleDto extends Article implements Serializable {
private String avatar;
private String username;
}

View File

@ -0,0 +1,41 @@
package com.zhangmeng.model.dto.article;
import com.zhangmeng.model.dto.comment.CommentModel;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class ArticleModel implements Serializable {
private Integer count;
private List<ArticleDto> articleDto_list;
private List<ArticleDto> latest_article_list;//最新推荐
private String blog_title;
//当前页
private int pageNum;
//每页的数量
private int pageSize;
//前一页
private int prePage;
//下一页
private int nextPage;
private String message;
private String QQ;
private String email;
private ArticleDto details;
List<CommentModel> commentModelList;//评论
}

View File

@ -0,0 +1,19 @@
package com.zhangmeng.model.dto.comment;
import com.zhangmeng.model.entity.Comment;
import com.zhangmeng.model.entity.Reply;
import com.zhangmeng.model.entity.User;
import lombok.Data;
import java.io.Serializable;
@Data
public class CommentModel implements Serializable {
private Comment comment;
private Reply reply;
private User reply_user;//回复的博主信息
}