2021年12月13日16:18:25
parent
156dd5b8b4
commit
c7680d4741
|
|
@ -50,4 +50,11 @@ public class BlogController extends BaseController {
|
|||
model.addAllAttributes(map);
|
||||
return this.jumpPage("blog/v1/category");
|
||||
}
|
||||
|
||||
@GetMapping("/about")
|
||||
public ModelAndView about(Model model) {
|
||||
Map<String,Object> map = this.articleFeign.blog_common_page();
|
||||
model.addAllAttributes(map);
|
||||
return this.jumpPage("blog/v1/about");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.zhangmeng.admin.manager.controller;
|
||||
|
||||
import com.zhangmeng.admin.manager.feign.ArticleFeign;
|
||||
import com.zhangmeng.admin.manager.feign.CategoryFeign;
|
||||
import com.zhangmeng.model.base.baseController.BaseController;
|
||||
import com.zhangmeng.model.entity.Category;
|
||||
|
|
@ -17,6 +18,9 @@ public class CategoryController extends BaseController {
|
|||
@Autowired
|
||||
private CategoryFeign categoryFeign;
|
||||
|
||||
@Autowired
|
||||
private ArticleFeign articleFeign;
|
||||
|
||||
@GetMapping("/index")
|
||||
public ModelAndView category_index() {
|
||||
return this.jumpPage("admin/category/list");
|
||||
|
|
@ -41,4 +45,10 @@ public class CategoryController extends BaseController {
|
|||
return this.jumpPage("admin/category/edit");
|
||||
}
|
||||
|
||||
@GetMapping("/category_list")
|
||||
public ModelAndView category_list(String categoryId, Integer pageNum, Integer pageSize, Model model) {
|
||||
model.addAllAttributes(this.categoryFeign.getMap(categoryId, pageNum, pageSize));
|
||||
model.addAllAttributes(this.articleFeign.blog_common_page());
|
||||
return this.jumpPage("blog/v1/category");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.GetMapping;
|
|||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@FeignClient(value = SysConstant.mystyle_cloud_blog,contextId = "CategoryFeign")
|
||||
public interface CategoryFeign {
|
||||
|
|
@ -16,4 +17,7 @@ public interface CategoryFeign {
|
|||
|
||||
@GetMapping("/category/findById")
|
||||
public Category findById(@RequestParam("categoryId") Long categoryId);
|
||||
|
||||
@GetMapping("/category/getMap")
|
||||
public Map<String,Object> getMap(@RequestParam("categoryId") String categoryId,@RequestParam("pageNum") Integer pageNum,@RequestParam("pageSize") Integer pageSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
<nav class="ui inverted attached segment m-padded-tb-mini ">
|
||||
<div class="ui container">
|
||||
<div class="ui inverted secondary stackable menu">
|
||||
<h2 class="ui teal header item">${blogTools.title()!}</h2>
|
||||
<a href="/blog/index" class="m-item item m-mobile-hide"><i class="mini home icon"></i> 首页</a>
|
||||
<a href="/blog/category" class=" m-item item m-mobile-hide"><i class="mini idea icon"></i> 分类</a>
|
||||
<a href="/blog/about" class="active m-item item m-mobile-hide"><i class="mini info icon"></i> 关于我</a>
|
||||
<h2 class="ui teal header item">${title!}</h2>
|
||||
<a href="/mystyle-cloud-web-blog/blog/index" class=" m-item item m-mobile-hide"><i class="mini home icon"></i> 首页</a>
|
||||
<a href="/mystyle-cloud-web-blog/category/category_list" class="m-item item m-mobile-hide"><i class="mini idea icon"></i> 分类</a>
|
||||
<a href="/mystyle-cloud-web-blog/blog/about" class="active m-item item m-mobile-hide"><i class="mini info icon"></i> 关于我</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -20,11 +20,11 @@
|
|||
<div class="ui container">
|
||||
|
||||
<div class="ui stackable grid">
|
||||
<#-- <div class="eleven wide column">-->
|
||||
<#-- <div class="ui segment">-->
|
||||
<#-- <img src="${user.avatar!}" width="803px" height="603px" alt="" class="ui rounded image">-->
|
||||
<#-- </div>-->
|
||||
<#-- </div>-->
|
||||
<div class="eleven wide column">
|
||||
<div class="ui segment">
|
||||
<img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F8289352170%2F1000&refer=http%3A%2F%2Finews.gtimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1638446949&t=586b2921c659eeb6813d4d241351cbd4" alt="" class="ui rounded image">
|
||||
</div>
|
||||
</div>
|
||||
<div class="sixteen wide column">
|
||||
<div class="ui top attached segment">
|
||||
<div class="ui header">转身的背影在心底沉沦</div>
|
||||
|
|
@ -40,15 +40,15 @@
|
|||
</p>
|
||||
</div>
|
||||
<div class="ui attached segment">
|
||||
<#if blogTools.tagsList() ??>
|
||||
<#list blogTools.tagsList() as tags>
|
||||
<#if tagsList ??>
|
||||
<#list tagsList as tags>
|
||||
<div class="ui orange basic left pointing label m-margin-tb-tiny">${tags.tagName!}</div>
|
||||
</#list>
|
||||
</#if>
|
||||
</div>
|
||||
<div class="ui attached segment">
|
||||
<#if blogTools.categoryList() ??>
|
||||
<#list blogTools.categoryList() as category>
|
||||
<#if categoryList ??>
|
||||
<#list categoryList as category>
|
||||
<div class="ui teal basic left pointing label m-margin-tb-tiny">${category.categoryName!}</div>
|
||||
</#list>
|
||||
</#if>
|
||||
|
|
|
|||
|
|
@ -4,10 +4,10 @@
|
|||
<nav class="ui inverted attached segment m-padded-tb-mini ">
|
||||
<div class="ui container">
|
||||
<div class="ui inverted secondary stackable menu">
|
||||
<h2 class="ui teal header item">${blogTools.title()!}</h2>
|
||||
<a href="/blog/index" class="m-item item m-mobile-hide"><i class="mini home icon"></i> 首页</a>
|
||||
<a href="/blog/category" class="active m-item item m-mobile-hide"><i class="mini idea icon"></i> 分类</a>
|
||||
<a href="/blog/about" class="m-item item m-mobile-hide"><i class="mini info icon"></i> 关于我</a>
|
||||
<h2 class="ui teal header item">${title}</h2>
|
||||
<a href="/mystyle-cloud-web-blog/blog/about" class=" m-item item m-mobile-hide"><i class="mini home icon"></i> 首页</a>
|
||||
<a href="/mystyle-cloud-web-blog/category/category_list" class="active m-item item m-mobile-hide"><i class="mini idea icon"></i> 分类</a>
|
||||
<a href="/mystyle-cloud-web-blog/blog/about" class="m-item item m-mobile-hide"><i class="mini info icon"></i> 关于我</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -26,14 +26,14 @@
|
|||
<h3 class="ui teal header">分类</h3>
|
||||
</div>
|
||||
<div class="right aligned column">
|
||||
共 <h2 class="ui orange header m-inline-block m-text-thin"> ${blogTools.category_count()!} </h2> 个
|
||||
共 <h2 class="ui orange header m-inline-block m-text-thin"> ${category_count!} </h2> 个
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ui attached segment m-padded-tb-large">
|
||||
<#if blogTools.categoryList()??>
|
||||
<#list blogTools.categoryList() as category>
|
||||
<#if categoryList??>
|
||||
<#list categoryList as category>
|
||||
<a href="/blog/category?categoryId=${category.id!}"
|
||||
<#if category.id == activedId>
|
||||
class="ui basic left pointing large label m-margin-tb-tiny teal">
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
class="header">${article.username!}</a></div>
|
||||
</div>
|
||||
<div class="item">
|
||||
<i class="calendar icon"></i><span>${article.addTime!?string('yyyy-MM-dd hh:mm:ss')}</span>
|
||||
<#-- <i class="calendar icon"></i><span>${article.addTime!?string('yyyy-MM-dd hh:mm:ss')}</span>-->
|
||||
</div>
|
||||
<div class="item">
|
||||
<i class="eye icon"></i> <span>${article.views!}</span>
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
<div class="ui container">
|
||||
<div class="ui inverted secondary stackable menu">
|
||||
<h2 class="ui teal header item">${title!}</h2>
|
||||
<a href="/blog/index" class="active m-item item m-mobile-hide"><i class="mini home icon"></i> 首页</a>
|
||||
<a href="/blog/category" class="m-item item m-mobile-hide"><i class="mini idea icon"></i> 分类</a>
|
||||
<a href="/blog/about" class="m-item item m-mobile-hide"><i class="mini info icon"></i> 关于我</a>
|
||||
<a href="/mystyle-cloud-web-blog/blog/index" class="active m-item item m-mobile-hide"><i class="mini home icon"></i> 首页</a>
|
||||
<a href="/mystyle-cloud-web-blog/category/category_list" class="m-item item m-mobile-hide"><i class="mini idea icon"></i> 分类</a>
|
||||
<a href="/mystyle-cloud-web-blog/blog/about" class="m-item item m-mobile-hide"><i class="mini info icon"></i> 关于我</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<h4 class="ui inverted header">最新博客</h4>
|
||||
<div class="ui inverted link list">
|
||||
<#list latest_blog as blog>
|
||||
<a href="/blog/${blog.id}" class="item">${blog.title!}</a>
|
||||
<a href="/mystyle-cloud-web-blog/blog/details/${blog.id}" class="item">${blog.title!}</a>
|
||||
</#list>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
<a href="/blog/document/index" target="_blank">
|
||||
<h2 class="ui teal header item">${title!}</h2>
|
||||
</a>
|
||||
<a href="/blog/index" class="active m-item item m-mobile-hide"><i class="mini home icon"></i> 首页</a>
|
||||
<a href="/blog/category" class="m-item item m-mobile-hide"><i class="mini idea icon"></i> 分类</a>
|
||||
<a href="/blog/about" class="m-item item m-mobile-hide"><i class="mini info icon"></i> 关于我</a>
|
||||
<a href="/mystyle-cloud-web-blog/blog/index" class="active m-item item m-mobile-hide"><i class="mini home icon"></i> 首页</a>
|
||||
<a href="/mystyle-cloud-web-blog/category/category_list" class="m-item item m-mobile-hide"><i class="mini idea icon"></i> 分类</a>
|
||||
<a href="/mystyle-cloud-web-blog/blog/about" class="m-item item m-mobile-hide"><i class="mini info icon"></i> 关于我</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -88,11 +88,11 @@
|
|||
<div class="ui bottom attached segment">
|
||||
<div class="ui middle aligned two column grid">
|
||||
<div class="column">
|
||||
<a href="/blog/index?pageNum=${articleModel.prePage!}&pageSize=${articleModel.pageSize!}" class="ui mini teal basic button">上一页</a>
|
||||
<a href="/mystyle-cloud-web-blog/blog/index?pageNum=${articleModel.prePage!}&pageSize=${articleModel.pageSize!}" class="ui mini teal basic button">上一页</a>
|
||||
</div>
|
||||
|
||||
<div class="right aligned column">
|
||||
<a href="/blog/index?pageNum=${articleModel.nextPage!}&pageSize=${articleModel.pageSize!}" class="ui mini teal basic button">下一页</a>
|
||||
<a href="/mystyle-cloud-web-blog/blog/index?pageNum=${articleModel.nextPage!}&pageSize=${articleModel.pageSize!}" class="ui mini teal basic button">下一页</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
@ -126,7 +126,7 @@
|
|||
<div class="ui fluid vertical menu">
|
||||
<#if categoryList??>
|
||||
<#list categoryList as category>
|
||||
<a href="/blog/category?categoryId=${category.id!}" class="item">
|
||||
<a href="/mystyle-cloud-web-blog/category/category_list?categoryId=${category.id!}" class="item">
|
||||
${category.categoryName!}
|
||||
<div class="ui teal basic left pointing label">${category.count!}</div>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -33,4 +33,7 @@ public interface CategoryControllerApi {
|
|||
|
||||
@ApiOperation("根据id查询")
|
||||
public Category findById(@RequestParam("categoryId") Long categoryId);
|
||||
|
||||
@GetMapping("/getMap")
|
||||
public Map<String,Object> getMap(String categoryId, Integer pageNum, Integer pageSize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,6 +256,7 @@ public class ArticleController extends BaseController implements ArticleControll
|
|||
map.put("latest_blog",blogTools.latest_blog());
|
||||
map.put("user",blogTools.userInfo());
|
||||
map.put("message",blogTools.message());
|
||||
map.put("tagsList",blogTools.tagsList());
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,16 +3,22 @@ package com.zhangmeng.blog.controller;
|
|||
import com.github.pagehelper.PageInfo;
|
||||
import com.zhangmeng.api.service.blog.CategoryControllerApi;
|
||||
import com.zhangmeng.blog.feign.UserFeign;
|
||||
import com.zhangmeng.blog.service.ArticleService;
|
||||
import com.zhangmeng.blog.service.CategoryService;
|
||||
import com.zhangmeng.blog.tools.BlogTools;
|
||||
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.query.QueryParams;
|
||||
import com.zhangmeng.model.dto.query.QueryResult;
|
||||
import com.zhangmeng.model.entity.Article;
|
||||
import com.zhangmeng.model.entity.Category;
|
||||
import com.zhangmeng.model.entity.User;
|
||||
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.*;
|
||||
|
|
@ -21,10 +27,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
|||
import tk.mybatis.mapper.entity.Condition;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@RestController
|
||||
|
|
@ -37,6 +40,12 @@ public class CategoryController extends BaseController implements CategoryContro
|
|||
@Autowired
|
||||
private UserFeign userFeign;
|
||||
|
||||
@Autowired
|
||||
private BlogTools blogTools;
|
||||
|
||||
@Autowired
|
||||
private ArticleService articleService;
|
||||
|
||||
@Override
|
||||
@PostMapping("/save")
|
||||
public Result save(@RequestParam @RequestBody Map<String,Object> map){
|
||||
|
|
@ -112,8 +121,49 @@ public class CategoryController extends BaseController implements CategoryContro
|
|||
return this.categoryService.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("findById")
|
||||
@GetMapping("/findById")
|
||||
public Category findById(@RequestParam("categoryId") Long categoryId){
|
||||
return this.categoryService.findById(categoryId);
|
||||
}
|
||||
|
||||
@GetMapping("/getMap")
|
||||
public Map<String,Object> getMap(String categoryId, Integer pageNum, Integer pageSize){
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("category_count",blogTools.category_count());
|
||||
map.put("categoryList",blogTools.categoryList());
|
||||
Long activedId = null;
|
||||
Condition condition = new Condition(Article.class);
|
||||
Example.Criteria criteria = condition.createCriteria();
|
||||
if (categoryId != null && !categoryId.equals("")) {
|
||||
activedId = Long.parseLong(categoryId);
|
||||
criteria.andEqualTo("category_id",Long.parseLong(categoryId));
|
||||
}else {
|
||||
List<Category> categoryList = this.categoryService.findAll();
|
||||
if (categoryList.size() > 0 ){
|
||||
activedId = categoryList.get(0).getId();
|
||||
}
|
||||
}
|
||||
PageInfo<Article> pageInfo = this.articleService.findByCondition(new QueryParams(pageNum, pageSize, condition,"addTime desc"), true);
|
||||
List<ArticleDto> articleDtoList = new ArrayList<>();
|
||||
if (pageInfo.getList().size() > 0){
|
||||
for (Article article : pageInfo.getList()) {
|
||||
ArticleDto articleDto = articleDto(article);
|
||||
User user = this.userFeign.findByUserId(article.getUser_id());
|
||||
articleDto.setUsername(user.getUsername());
|
||||
articleDto.setAvatar(user.getAvatar());
|
||||
articleDtoList.add(articleDto);
|
||||
}
|
||||
}
|
||||
QueryResult<ArticleDto> queryResult = blogTools.queryResult(pageInfo, articleDtoList);
|
||||
map.put("queryResult",queryResult);
|
||||
map.put("activedId",activedId);
|
||||
return map;
|
||||
}
|
||||
|
||||
private ArticleDto articleDto(Article article) {
|
||||
ArticleDto articleDto = new ArticleDto();
|
||||
BeanUtils.copyProperties(article, articleDto);
|
||||
return articleDto;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -62,6 +62,7 @@ mystyle:
|
|||
- /article/findById
|
||||
- /article/blog_common_page
|
||||
- /article/comment_list
|
||||
- /category/getMap
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
|
|
|
|||
Loading…
Reference in New Issue