修改首页 2021年11月9日11:31:29
parent
86ee721824
commit
9ecc43107f
|
|
@ -1,10 +1,19 @@
|
|||
package com.zhangmeng.admin.manager.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zhangmeng.admin.manager.feign.ArticleFeign;
|
||||
import com.zhangmeng.admin.manager.service.PermissionService;
|
||||
import com.zhangmeng.admin.manager.service.SysLogService;
|
||||
import com.zhangmeng.admin.manager.service.UserService;
|
||||
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.Menu;
|
||||
import com.zhangmeng.model.dto.query.QueryParams;
|
||||
import com.zhangmeng.model.entity.Article;
|
||||
import com.zhangmeng.model.entity.Permission;
|
||||
import com.zhangmeng.model.entity.SysLog;
|
||||
import com.zhangmeng.model.entity.User;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.bouncycastle.math.raw.Mod;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -15,9 +24,9 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
import tk.mybatis.mapper.entity.Condition;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author zhangmeng
|
||||
|
|
@ -34,6 +43,15 @@ public class UrlRequestController extends BaseController {
|
|||
@Autowired
|
||||
private PermissionService permissionService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private SysLogService sysLogService;
|
||||
|
||||
@Autowired
|
||||
private ArticleFeign articleFeign;
|
||||
|
||||
//跳转首页
|
||||
@GetMapping({"/login","/"})
|
||||
public ModelAndView login (){
|
||||
|
|
@ -56,4 +74,54 @@ public class UrlRequestController extends BaseController {
|
|||
List<Permission> permissions = this.permissionService.findByUserId(this.userUtil.currentUser().getId());
|
||||
return this.permissionService.toUserMenus(permissions, 0L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Describe: 获取主页视图
|
||||
* Param: ModelAndView
|
||||
* Return: 主页视图
|
||||
*/
|
||||
@ApiIgnore
|
||||
@GetMapping("/admin/home")
|
||||
public ModelAndView home(Model model) {
|
||||
User loginUser = this.userUtil.currentUser();
|
||||
model.addAttribute("loginUser", loginUser);
|
||||
//用户人数
|
||||
Integer user_count = this.userService.selectCountEq("deleteStatus", false);
|
||||
model.addAttribute("user_count",user_count);
|
||||
//文章数量
|
||||
Integer article_count = this.articleFeign.selectCountEq( false);
|
||||
model.addAttribute("article_count",article_count);
|
||||
//小说数量
|
||||
model.addAttribute("fiction_count",16);
|
||||
//消息数量
|
||||
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<>();
|
||||
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);
|
||||
//日志
|
||||
List<SysLog> sysLogs = this.sysLogService.findAll(new QueryParams(1, 10, "addTime desc"));
|
||||
List<Map<String,Object>> list = new ArrayList<>();
|
||||
if (sysLogs.size()>0){
|
||||
for (SysLog sysLog : sysLogs) {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
User user = this.userService.findById(sysLog.getUser_id());
|
||||
map.put("avatar",user.getAvatar() == null ? "/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);
|
||||
list.add(map);
|
||||
}
|
||||
}
|
||||
model.addAttribute("sysLogs",list);
|
||||
return jumpPage("admin/home/home");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package com.zhangmeng.admin.manager.dao;
|
||||
|
||||
import com.zhangmeng.model.base.baseDao.AbstractBaseMapper;
|
||||
import com.zhangmeng.model.entity.SysLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* @author zhengmeng
|
||||
* @version 1.0
|
||||
* @date 2021年1月7日17:44:40
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysLogDao extends AbstractBaseMapper<SysLog> {
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.zhangmeng.admin.manager.feign;
|
||||
|
||||
import com.zhangmeng.model.dto.SysConstant;
|
||||
import com.zhangmeng.model.dto.query.QueryParams;
|
||||
import com.zhangmeng.model.entity.Article;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(SysConstant.mystyle_cloud_blog)
|
||||
public interface ArticleFeign {
|
||||
|
||||
@GetMapping("/article/selectCountByDayOfPass")
|
||||
List<Integer> selectCountByDayOfPass(@RequestParam(value = "x_date", defaultValue = "forezp",required = false) List<String> x_date);
|
||||
|
||||
@GetMapping("/article/selectCountEq")
|
||||
Integer selectCountEq(@RequestParam(value = "deleteStatus", defaultValue = "forezp",required = false)boolean deleteStatus);
|
||||
|
||||
@GetMapping("/article/findByCondition")
|
||||
List<Article> findByCondition();
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.zhangmeng.admin.manager.service;
|
||||
|
||||
import com.zhangmeng.model.base.baseService.BaseService;
|
||||
import com.zhangmeng.model.entity.SysLog;
|
||||
|
||||
public interface SysLogService extends BaseService<SysLog> {
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.zhangmeng.admin.manager.service.impl;
|
||||
|
||||
import com.zhangmeng.admin.manager.service.SysLogService;
|
||||
import com.zhangmeng.model.base.baseService.impl.AbstractBaseServiceImpl;
|
||||
import com.zhangmeng.model.entity.SysLog;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SysLogServiceImpl extends AbstractBaseServiceImpl<SysLog> implements SysLogService {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>mystyle-cloud-parent</artifactId>
|
||||
<groupId>com.zhangmeng</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>mystyle-cloud-blog</artifactId>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.zhangmeng</groupId>
|
||||
<artifactId>mystyle-cloud-api</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-openfeign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-sleuth</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-sleuth-zipkin</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.zhangmeng.blog;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
@EnableFeignClients
|
||||
@ComponentScan(basePackages = {"com.zhangmeng.model","com.zhangmeng.blog","com.zhangmeng.api"})
|
||||
public class BlogApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BlogApplication.class,args);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
package com.zhangmeng.blog.config.security;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
|
||||
import org.springframework.security.oauth2.provider.token.TokenStore;
|
||||
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
|
||||
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 转身的背影在心底里沉沦
|
||||
* @date 2021年9月14日16:45:29
|
||||
* @version 1.0
|
||||
*/
|
||||
@Configuration
|
||||
@EnableResourceServer
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)// 激活方法上的PreAuthorize注解
|
||||
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
|
||||
|
||||
// 公钥
|
||||
private static final String PUBLIC_KEY = "public.key";
|
||||
|
||||
@Autowired
|
||||
private SecurityProperty securityProperty;
|
||||
|
||||
/***
|
||||
* 定义JwtTokenStore
|
||||
* @param jwtAccessTokenConverter
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public TokenStore tokenStore(JwtAccessTokenConverter jwtAccessTokenConverter) {
|
||||
return new JwtTokenStore(jwtAccessTokenConverter);
|
||||
}
|
||||
|
||||
/***
|
||||
* 定义JJwtAccessTokenConverter
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public JwtAccessTokenConverter jwtAccessTokenConverter() {
|
||||
JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
|
||||
converter.setVerifierKey(getPubKey()); //秘钥的一部分
|
||||
return converter;
|
||||
}
|
||||
/**
|
||||
* 获取非对称加密公钥 Key
|
||||
* @return 公钥 Key
|
||||
*/
|
||||
private String getPubKey() {
|
||||
Resource resource = new ClassPathResource(PUBLIC_KEY);
|
||||
try {
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(resource.getInputStream());
|
||||
BufferedReader br = new BufferedReader(inputStreamReader);
|
||||
return br.lines().collect(Collectors.joining("\n"));
|
||||
} catch (IOException ioe) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* SpringSecurity
|
||||
* Http安全配置,对每个到达系统的http请求链接进行校验
|
||||
* @param http
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void configure(HttpSecurity http) throws Exception {
|
||||
// 所有请求必须认证通过
|
||||
http.authorizeRequests()
|
||||
// 跨域预检请求
|
||||
.antMatchers(HttpMethod.OPTIONS, "/**").permitAll()
|
||||
.antMatchers(securityProperty.getOpenApi()).permitAll()
|
||||
.anyRequest().
|
||||
authenticated(); // 其他地址需要认证授权
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.zhangmeng.blog.config.security;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author 转身的背影在心底里沉沦
|
||||
* @date 2021年9月14日16: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;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,175 @@
|
|||
package com.zhangmeng.blog.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zhangmeng.blog.feign.UserFeign;
|
||||
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.query.QueryParams;
|
||||
import com.zhangmeng.model.entity.Article;
|
||||
import com.zhangmeng.model.entity.Category;
|
||||
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.factory.annotation.Autowired;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
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;
|
||||
|
||||
@Api(tags = "文章管理")
|
||||
@RestController
|
||||
@RequestMapping("/article")
|
||||
public class ArticleController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private ArticleService articleService;
|
||||
|
||||
@Autowired
|
||||
private CategoryService categoryService;
|
||||
|
||||
@Autowired
|
||||
private UserFeign userFeign;
|
||||
|
||||
@ApiOperation("文章保存")
|
||||
@PostMapping("/save")
|
||||
public Result save(@RequestParam @RequestBody Map<String, Object> parms) {
|
||||
String articleId = CommonUtil.map_get_value(parms, "articleId");
|
||||
Article article = null;
|
||||
boolean flag = false;
|
||||
if (CommonUtil.isNull(articleId)) {
|
||||
article = new Article();
|
||||
article.setAddTime(new Date());
|
||||
article.setUpdateTime(new Date());
|
||||
article.setDeleteStatus(false);
|
||||
flag = true;
|
||||
} else {
|
||||
article = this.articleService.findById(Long.parseLong(articleId));
|
||||
}
|
||||
|
||||
String title = CommonUtil.map_get_value(parms, "title");
|
||||
if (CommonUtil.isNotNull(title)) {
|
||||
article.setTitle(title);
|
||||
}
|
||||
|
||||
String intro = CommonUtil.map_get_value(parms, "intro");
|
||||
if (CommonUtil.isNotNull(intro)) {
|
||||
article.setIntro(intro);
|
||||
}
|
||||
|
||||
String categoryId = CommonUtil.map_get_value(parms, "categoryId");
|
||||
if (CommonUtil.isNotNull(categoryId) && !categoryId.equals("0")) {
|
||||
article.setCategory_id(Long.parseLong(categoryId));
|
||||
Category category = this.categoryService.findById(Long.parseLong(categoryId));
|
||||
article.setCategoryName(category.getCategoryName());
|
||||
}
|
||||
|
||||
String content_editormd_markdown_doc = CommonUtil.map_get_value(parms, "content-editormd-markdown-doc");
|
||||
if (CommonUtil.isNotNull(content_editormd_markdown_doc)) {
|
||||
article.setContentEditormdMarkdownDoc(content_editormd_markdown_doc);
|
||||
}
|
||||
|
||||
String content_editormd_html_code = CommonUtil.map_get_value(parms, "content-editormd-html-code");
|
||||
if (CommonUtil.isNotNull(content_editormd_html_code)) {
|
||||
article.setContent(content_editormd_html_code);
|
||||
article.setContentEditormdHtmlCode(content_editormd_html_code);
|
||||
}
|
||||
|
||||
String keyWords = CommonUtil.map_get_value(parms, "keyWords");
|
||||
if (CommonUtil.isNotNull(keyWords)) {
|
||||
article.setKeyWords(keyWords);
|
||||
}
|
||||
|
||||
String status = CommonUtil.map_get_value(parms, "status");
|
||||
if (CommonUtil.isNotNull(status)) {
|
||||
Article.Status status1 = CommonUtil.getEnum(status, Article.Status.class);
|
||||
article.setStatus(status1);
|
||||
}
|
||||
|
||||
//article_upload_image
|
||||
String article_upload_image = CommonUtil.map_get_value(parms, "article_upload_image");
|
||||
String file_id = CommonUtil.map_get_value(parms, "file_id");
|
||||
if (CommonUtil.isNotNull(article_upload_image)){
|
||||
article.setPhotoPath(article_upload_image);
|
||||
article.setPhoto_id(Long.parseLong(file_id));
|
||||
}
|
||||
if (flag){
|
||||
article.setViews(0);
|
||||
article.setUser_id(this.userFeign.getCurrentUser() == null ? 1L:this.userFeign.getCurrentUser().getId());
|
||||
article.setUsername(this.userFeign.getCurrentUser() == null? "admin":this.userFeign.getCurrentUser().getUsername());
|
||||
this.articleService.save(article);
|
||||
//存放链接
|
||||
article.setLinks("/blog/details/"+article.getId());
|
||||
this.articleService.update(article);
|
||||
}else {
|
||||
this.articleService.update(article);
|
||||
}
|
||||
return this.success("保存成功");
|
||||
}
|
||||
|
||||
@ApiOperation("文章列表")
|
||||
@GetMapping("/list")
|
||||
public Result list(Integer pageNum, Integer pageSize, String startTime, String endTime, String title,Long categoryId) {
|
||||
Condition condition = new Condition(Article.class);
|
||||
Example.Criteria criteria = condition.createCriteria();
|
||||
if (startTime != null && !startTime.equals("") && endTime != null && !endTime.equals("")) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("");
|
||||
criteria.andBetween("addTime", startTime, endTime);
|
||||
}
|
||||
if (title != null) {
|
||||
criteria.andLike("title", "%" + title + "%");
|
||||
}
|
||||
if (categoryId != null && categoryId != 0L){
|
||||
criteria.andEqualTo("category_id",categoryId);
|
||||
}
|
||||
criteria.andEqualTo("deleteStatus", false);
|
||||
PageInfo<Article> pageInfo = this.articleService.findByCondition(new QueryParams(pageNum, pageSize, condition),true);
|
||||
return new Result(true, StatusCode.OK, "查询成功", pageInfo.getTotal(),pageInfo.getList());
|
||||
}
|
||||
|
||||
@ApiOperation("删除文章")
|
||||
@PostMapping("/delete")
|
||||
public Result delete( String articleId) {
|
||||
if (CommonUtil.isNotNull(articleId)){
|
||||
this.articleService.deleteById(Long.parseLong(articleId));
|
||||
}
|
||||
return new Result(true,StatusCode.OK,"删除成功");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除文章")
|
||||
@PostMapping("/batchRemove")
|
||||
public Result batchRemove( String ids) {
|
||||
String id_s = CommonUtil.firstLastComma(ids);
|
||||
String[] strings = id_s.split(",");
|
||||
if (strings.length > 0){
|
||||
for (String id : strings) {
|
||||
this.articleService.deleteById(Long.parseLong(id));
|
||||
}
|
||||
}
|
||||
return new Result(true,StatusCode.OK,"删除成功");
|
||||
}
|
||||
|
||||
@GetMapping("/selectCountByDayOfPass")
|
||||
public List<Integer> selectCountByDayOfPass(List<String> x_date){
|
||||
return this.articleService.selectCountByDayOfPass(x_date);
|
||||
}
|
||||
|
||||
@GetMapping("/selectCountByDayOfPass")
|
||||
public List<Integer> selectCountByDayOfPass(List<String> x_date){
|
||||
return this.articleService.selectCountByDayOfPass(x_date);
|
||||
}
|
||||
|
||||
@GetMapping("/findByCondition")
|
||||
public List<Article> findByCondition(){
|
||||
return this.articleService.findByCondition(new QueryParams(new Condition(Article.class)));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.zhangmeng.blog.dao;
|
||||
|
||||
|
||||
import com.zhangmeng.model.base.baseDao.AbstractBaseMapper;
|
||||
import com.zhangmeng.model.entity.Article;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
|
||||
/**
|
||||
* @author zhengmeng
|
||||
* @version 1.0
|
||||
* @date 2021年1月7日17:44:40
|
||||
*/
|
||||
@Mapper
|
||||
public interface ArticleDao extends AbstractBaseMapper<Article> {
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.zhangmeng.blog.dao;
|
||||
|
||||
|
||||
import com.zhangmeng.model.base.baseDao.AbstractBaseMapper;
|
||||
import com.zhangmeng.model.entity.Category;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CategoryDao extends AbstractBaseMapper<Category> {
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.zhangmeng.blog.dao;
|
||||
|
||||
import com.zhangmeng.model.base.baseDao.AbstractBaseMapper;
|
||||
import com.zhangmeng.model.entity.Comment;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CommentDao extends AbstractBaseMapper<Comment> {
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.zhangmeng.blog.feign;
|
||||
|
||||
import com.zhangmeng.model.dto.SysConstant;
|
||||
import com.zhangmeng.model.entity.User;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@FeignClient(SysConstant.mystyle_cloud_blog)
|
||||
public interface UserFeign {
|
||||
|
||||
@GetMapping("")
|
||||
public User getCurrentUser();
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.zhangmeng.blog.service;
|
||||
|
||||
import com.zhangmeng.model.base.baseService.BaseService;
|
||||
import com.zhangmeng.model.entity.Article;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ArticleService extends BaseService<Article> {
|
||||
List<Integer> selectCountByDayOfPass(List<String> x_date);
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.zhangmeng.blog.service;
|
||||
|
||||
|
||||
import com.zhangmeng.model.base.baseService.BaseService;
|
||||
import com.zhangmeng.model.entity.Category;
|
||||
|
||||
public interface CategoryService extends BaseService<Category> {
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.zhangmeng.blog.service;
|
||||
|
||||
|
||||
import com.zhangmeng.model.base.baseService.BaseService;
|
||||
import com.zhangmeng.model.entity.Comment;
|
||||
|
||||
public interface CommentService extends BaseService<Comment> {
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.zhangmeng.blog.service.impl;
|
||||
|
||||
import com.zhangmeng.blog.service.ArticleService;
|
||||
import com.zhangmeng.model.base.baseService.impl.AbstractBaseServiceImpl;
|
||||
import com.zhangmeng.model.base.baseUtil.CommonUtil;
|
||||
import com.zhangmeng.model.dto.date.DateBean;
|
||||
import com.zhangmeng.model.entity.Article;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tk.mybatis.mapper.entity.Condition;
|
||||
import tk.mybatis.mapper.entity.Example;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ArticleServiceImpl extends AbstractBaseServiceImpl<Article> implements ArticleService {
|
||||
|
||||
@Override
|
||||
public List<Integer> selectCountByDayOfPass(List<String> x_date) {
|
||||
List<Integer> integerList = new ArrayList<>();
|
||||
if (x_date.size() > 0 ){
|
||||
for (String date : x_date) {
|
||||
integerList.add(today_article_count(date));
|
||||
}
|
||||
}
|
||||
return integerList;
|
||||
}
|
||||
|
||||
//获取当天的文章数量
|
||||
private Integer today_article_count(String date){
|
||||
Condition condition = new Condition(Article.class);
|
||||
Example.Criteria criteria = condition.createCriteria();
|
||||
DateBean dateBean = CommonUtil.day_of_bean(date);
|
||||
criteria.andBetween("addTime",dateBean.getBegin(),dateBean.getEnd());
|
||||
return this.selectCountByCondition(condition);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.zhangmeng.blog.service.impl;
|
||||
|
||||
import com.zhangmeng.blog.service.CategoryService;
|
||||
import com.zhangmeng.model.base.baseService.impl.AbstractBaseServiceImpl;
|
||||
import com.zhangmeng.model.entity.Category;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class CategoryServiceImpl extends AbstractBaseServiceImpl<Category> implements CategoryService {
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package com.zhangmeng.blog.service.impl;
|
||||
|
||||
|
||||
import com.zhangmeng.blog.service.CommentService;
|
||||
import com.zhangmeng.model.base.baseService.impl.AbstractBaseServiceImpl;
|
||||
import com.zhangmeng.model.entity.Comment;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class CommentServiceImpl extends AbstractBaseServiceImpl<Comment> implements CommentService {
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
server:
|
||||
port: 31007
|
||||
spring:
|
||||
application:
|
||||
name: mystyle-cloud-blog
|
||||
datasource:
|
||||
username: root
|
||||
password: root
|
||||
url: jdbc:mysql://127.0.0.1:3306/mystyle-blog?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
jpa:
|
||||
database: mysql
|
||||
hibernate:
|
||||
ddl-auto: update
|
||||
naming:
|
||||
physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
|
||||
show-sql: true
|
||||
properties:
|
||||
hibernate:
|
||||
dialect: org.hibernate.dialect.MySQL5Dialect
|
||||
zipkin:
|
||||
sender:
|
||||
type: web
|
||||
base-url: http://localhost:9411/
|
||||
service:
|
||||
name: mystyle-cloud-blog
|
||||
sleuth:
|
||||
sampler:
|
||||
probability: 1
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 127.0.0.1:8848
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
mybatis:
|
||||
type-aliases-package: com.zhangmeng.model.entity
|
||||
configuration:
|
||||
mapUnderscoreToCamelCase: true
|
||||
default-enum-type-handler: org.apache.ibatis.type.EnumOrdinalTypeHandler
|
||||
mapper:
|
||||
style: normal
|
||||
enum-as-simple-type: true
|
||||
identity: MYSQL
|
||||
check-example-entity-class: true
|
||||
|
||||
mystyle:
|
||||
security:
|
||||
open-api:
|
||||
#swagger-ui.html
|
||||
- /swagger-ui.html
|
||||
- /swagger-ui/**
|
||||
- /swagger-resources/**
|
||||
- /v2/api-docs
|
||||
- /v3/api-docs
|
||||
- /doc.html
|
||||
- /webjars/**
|
||||
|
|
@ -0,0 +1 @@
|
|||
-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAizuj0fBV2+dj4lM3G6efKYvC2czd07BqmzV++E2yBguVks3XWvsW8qlzmG+t1XBCnRFDI/t1Ddc/Jsnlfy4YzRN8otb/Xn6Yz9ACFvZIPGx/q0cqcrgVaR9rSQiSzsGTgUGHNJk8r3A4w9PSSB552Z9s6p5TsWK5ezlfgg+2ANKn1eJ6R/hzajS/B1bTAqYcl9ddo7prneoeAN5LjlMhc2e0cSVgQt8ALP+4x/bTMnDkMjG6R8lnDAxE27B2ZPaLOIOjkUMK+9mZa4RNBoCDG6J/fwPD1NUoVRCbyr/TVaS4EzyhfNK1QW3BlZ0NLSI/SFD3eryKaFQdacJHS31neQIDAQAB-----END PUBLIC KEY-----
|
||||
|
|
@ -39,12 +39,18 @@ spring:
|
|||
- id: mystyle-cloud-oauth
|
||||
uri: lb://mystyle-cloud-oauth
|
||||
predicates:
|
||||
- Path=/mystyle-cloud-oauth/**
|
||||
- Path=/oauth/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
- id: mystyle-cloud-admin-manager
|
||||
uri: lb://mystyle-cloud-admin-manager
|
||||
predicates:
|
||||
- Path=/mystyle-cloud-admin-manager/**
|
||||
- Path=/manager/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
- id: mystyle-cloud-blog
|
||||
uri: lb://mystyle-cloud-blog
|
||||
predicates:
|
||||
- Path=/blog/**
|
||||
filters:
|
||||
- StripPrefix=1
|
||||
|
|
@ -17,8 +17,8 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>6</source>
|
||||
<target>6</target>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,14 @@
|
|||
package com.zhangmeng.model.base.baseUtil;
|
||||
|
||||
import com.zhangmeng.model.dto.date.DateBean;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommonUtil {
|
||||
|
|
@ -11,6 +17,10 @@ public class CommonUtil {
|
|||
return object != null && !"".equals(object);
|
||||
}
|
||||
|
||||
public static boolean isNull(Object object) {
|
||||
return object == null || "".equals(object);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T, K, V> T map_get_value(Map<K, V> map, T t) {
|
||||
return (T) map.get(t);
|
||||
|
|
@ -190,4 +200,146 @@ public class CommonUtil {
|
|||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 当天时间封装
|
||||
*
|
||||
* @param date 当前时间 YYYY_MM_DD
|
||||
* @return DateBean
|
||||
*/
|
||||
public static DateBean day_of_bean(String date) {
|
||||
LocalDate now = LocalDate.parse(date, DateTimeFormatter.ofPattern(YYYY_MM_DD));
|
||||
LocalDateTime today_start = LocalDateTime.of(now, LocalTime.MIN);//当天零点
|
||||
LocalDateTime today_end = LocalDateTime.of(now, LocalTime.MAX);//当天零点
|
||||
DateBean dateBean = new DateBean();
|
||||
dateBean.setBegin(asDate(today_start));
|
||||
dateBean.setEnd(asDate(today_end));
|
||||
return dateBean;
|
||||
}
|
||||
|
||||
public static Date asDate(LocalDate localDate) {
|
||||
return Date.from(localDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
public static Date asDate(LocalDateTime localDateTime) {
|
||||
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
|
||||
public static LocalDate asLocalDate(Date date) {
|
||||
return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
}
|
||||
|
||||
public static LocalDateTime asLocalDateTime(Date date) {
|
||||
return Instant.ofEpochMilli(date.getTime()).atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 过去 ${n} 天 日期 集合
|
||||
*
|
||||
* @param n 过去的天数
|
||||
*/
|
||||
public static List<String> day_of_pass(int n) {
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(YYYY_MM_DD);
|
||||
List<String> date_list = new ArrayList<>();
|
||||
LocalDate today = LocalDate.now();
|
||||
for (int i = n; i > 0; i--) {
|
||||
LocalDate localDate = today.plusDays(-i);
|
||||
String format = dateTimeFormatter.format(localDate);
|
||||
date_list.add(format);
|
||||
}
|
||||
//加上今天
|
||||
date_list.add(dateTimeFormatter.format(today));
|
||||
return date_list;
|
||||
}
|
||||
|
||||
private static final long ONE_MINUTE = 60000L;
|
||||
|
||||
private static final long ONE_HOUR = 3600000L;
|
||||
|
||||
private static final long ONE_DAY = 86400000L;
|
||||
|
||||
private static final long ONE_WEEK = 604800000L;
|
||||
|
||||
private static final String ONE_SECOND_AGO = "秒前";
|
||||
|
||||
private static final String ONE_MINUTE_AGO = "分钟前";
|
||||
|
||||
private static final String ONE_HOUR_AGO = "小时前";
|
||||
|
||||
private static final String ONE_DAY_AGO = "天前";
|
||||
|
||||
private static final String ONE_MONTH_AGO = "月前";
|
||||
|
||||
private static final String ONE_YEAR_AGO = "年前";
|
||||
|
||||
private static long toSeconds(long date) {
|
||||
return date / 1000L;
|
||||
}
|
||||
|
||||
|
||||
private static long toMinutes(long date) {
|
||||
return toSeconds(date) / 60L;
|
||||
}
|
||||
|
||||
|
||||
private static long toHours(long date) {
|
||||
return toMinutes(date) / 60L;
|
||||
}
|
||||
|
||||
|
||||
private static long toDays(long date) {
|
||||
return toHours(date) / 24L;
|
||||
}
|
||||
|
||||
|
||||
private static long toMonths(long date) {
|
||||
return toDays(date) / 30L;
|
||||
}
|
||||
|
||||
|
||||
private static long toYears(long date) {
|
||||
return toMonths(date) / 365L;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算时间至当前时间 时间差
|
||||
*
|
||||
* @param date 日期
|
||||
* @return string
|
||||
*/
|
||||
public static String date_difference(Date date) {
|
||||
long delta = new Date().getTime() - date.getTime();
|
||||
if (delta < ONE_MINUTE) {
|
||||
long seconds = toSeconds(delta);
|
||||
return (seconds <= 0 ? 1 : seconds) + ONE_SECOND_AGO;
|
||||
}
|
||||
|
||||
if (delta < 45L * ONE_MINUTE) {
|
||||
long minutes = toMinutes(delta);
|
||||
return (minutes <= 0 ? 1 : minutes) + ONE_MINUTE_AGO;
|
||||
}
|
||||
|
||||
if (delta < 24L * ONE_HOUR) {
|
||||
long hours = toHours(delta);
|
||||
return (hours <= 0 ? 1 : hours) + ONE_HOUR_AGO;
|
||||
}
|
||||
|
||||
if (delta < 48L * ONE_HOUR) {
|
||||
return "昨天";
|
||||
}
|
||||
|
||||
if (delta < 30L * ONE_DAY) {
|
||||
long days = toDays(delta);
|
||||
return (days <= 0 ? 1 : days) + ONE_DAY_AGO;
|
||||
}
|
||||
|
||||
if (delta < 12L * 4L * ONE_WEEK) {
|
||||
long months = toMonths(delta);
|
||||
return (months <= 0 ? 1 : months) + ONE_MONTH_AGO;
|
||||
} else {
|
||||
long years = toYears(delta);
|
||||
return (years <= 0 ? 1 : years) + ONE_YEAR_AGO;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,4 +9,6 @@ public class SysConstant {
|
|||
|
||||
public static final String mystyle_cloud_oauth = "mystyle-cloud-oauth";
|
||||
|
||||
public static final String mystyle_cloud_blog = "mystyle-cloud-blog";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.zhangmeng.model.dto.date;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class DateBean implements Serializable {
|
||||
|
||||
private Date begin; //开始时间
|
||||
|
||||
private Date end; //结束时间
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
package com.zhangmeng.model.entity;
|
||||
|
||||
|
||||
import com.zhangmeng.model.base.baseEntity.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author zhengmeng
|
||||
* @version 1.0
|
||||
* @date 2021年1月7日11:38:42
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = "article")
|
||||
public class Article extends BaseEntity<Long> {
|
||||
|
||||
public enum Status {
|
||||
Enable("启用"),
|
||||
DisEnable("禁用");
|
||||
|
||||
Status(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
private String description;//描述
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
private String title;
|
||||
|
||||
@Column(columnDefinition = "longtext")
|
||||
private String intro;
|
||||
|
||||
@Column(columnDefinition = "longtext")
|
||||
private String content;
|
||||
|
||||
@Column(columnDefinition = "longtext")
|
||||
private String contentEditormdHtmlCode;
|
||||
|
||||
@Column(columnDefinition = "longtext")
|
||||
private String contentEditormdMarkdownDoc;
|
||||
|
||||
private Long category_id;//分类
|
||||
|
||||
@Column(columnDefinition = "longtext")
|
||||
private String categoryName;//分类名称
|
||||
|
||||
private Long photo_id;
|
||||
|
||||
@Column(columnDefinition = "longtext")
|
||||
private String photoPath;//图片路径
|
||||
|
||||
private Long tags_id;
|
||||
|
||||
private String keyWords;//关键词
|
||||
|
||||
private Status status;
|
||||
|
||||
private String tagsName;
|
||||
|
||||
private String links;//链接
|
||||
|
||||
private Long user_id;
|
||||
|
||||
private String username;//发布者的用户名
|
||||
|
||||
private Integer views;//访问量
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package com.zhangmeng.model.entity;
|
||||
|
||||
import com.zhangmeng.model.base.baseEntity.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author zhengmeng
|
||||
* @version 1.0
|
||||
* @date 2021年1月7日17:44:40
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = "category")
|
||||
public class Category extends BaseEntity<Long> {
|
||||
|
||||
public enum Type {
|
||||
Fiction("小说"),
|
||||
Blog_Article("博客文章") ;
|
||||
|
||||
private String description;//描述
|
||||
|
||||
Type(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
private String categoryName;
|
||||
|
||||
private String description;
|
||||
|
||||
private Type type;
|
||||
|
||||
private Long createUserId;
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package com.zhangmeng.model.entity;
|
||||
|
||||
import com.zhangmeng.model.base.baseEntity.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 评论
|
||||
*
|
||||
* @author zhengmeng
|
||||
* @version 1.0
|
||||
* @date 2021年1月7日17:44:40
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = "comment")
|
||||
public class Comment extends BaseEntity<Long> {
|
||||
|
||||
private Long article_id;//评论文章的id
|
||||
|
||||
private Long user_id;//评论者的id
|
||||
|
||||
private String QQ;//评论者的qq
|
||||
|
||||
private String email;//评论者的邮箱
|
||||
|
||||
private String content;//评论的内容
|
||||
|
||||
private String nickName;//评论者的称呼(昵称)回复
|
||||
|
||||
private String id_worker;//评论者唯一标识
|
||||
|
||||
private Long parentId;//上级id
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package com.zhangmeng.model.entity;
|
||||
|
||||
import com.zhangmeng.model.base.baseEntity.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**回复
|
||||
*
|
||||
* @author zhengmeng
|
||||
* @version 1.0
|
||||
* @date 2021年1月7日17:44:40
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = "reply")
|
||||
public class Reply extends BaseEntity<Long> {
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String content;
|
||||
|
||||
private String username;
|
||||
|
||||
private Long article_id;//回复的文章的id
|
||||
|
||||
private Long comment_id;//评论的的id
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.zhangmeng.model.entity;
|
||||
|
||||
import com.zhangmeng.model.base.baseEntity.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @author zhengmeng
|
||||
* @version 1.0
|
||||
* @date 2021年1月7日11:38:42
|
||||
*/
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = "sys_log")
|
||||
public class SysLog extends BaseEntity<Long> {
|
||||
|
||||
public enum LoggingType{
|
||||
LOGIN("登录"),
|
||||
LOGIN_OUT("退出");
|
||||
|
||||
LoggingType(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
private String description;//描述
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private String serial_number;
|
||||
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 日 志 类 型
|
||||
*/
|
||||
private LoggingType loggingType;
|
||||
|
||||
/**
|
||||
* 异 常 信 息
|
||||
*/
|
||||
private String errorMsg;
|
||||
|
||||
/**
|
||||
* 操 作 人 员
|
||||
*/
|
||||
private Long user_id;
|
||||
|
||||
/**
|
||||
* 扩 展 信 息
|
||||
*/
|
||||
|
||||
private String expandInfoJSON;
|
||||
}
|
||||
Loading…
Reference in New Issue