空间首页增加列表查询,编辑查看优化
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
<fastjson.version>1.2.53</fastjson.version>
|
<fastjson.version>1.2.53</fastjson.version>
|
||||||
|
<pagehelper.version>4.1.6</pagehelper.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -35,5 +36,10 @@
|
|||||||
<artifactId>fastjson</artifactId>
|
<artifactId>fastjson</artifactId>
|
||||||
<version>${fastjson.version}</version>
|
<version>${fastjson.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<dependency>
|
||||||
|
<groupId>com.github.pagehelper</groupId>
|
||||||
|
<artifactId>pagehelper</artifactId>
|
||||||
|
<version>${pagehelper.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.zyplayer.doc.core.json;
|
|||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||||
import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;
|
import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
@@ -25,13 +26,21 @@ public class DocResponseJson<T> implements ResponseJson<T> {
|
|||||||
@ApiModelProperty(value = "返回值说明")
|
@ApiModelProperty(value = "返回值说明")
|
||||||
private String errMsg;
|
private String errMsg;
|
||||||
@ApiModelProperty(value = "返回数据")
|
@ApiModelProperty(value = "返回数据")
|
||||||
private T data;
|
private Object data;
|
||||||
|
@ApiModelProperty(value = "总数")
|
||||||
|
private Long total;
|
||||||
|
@ApiModelProperty(value = "当前页数")
|
||||||
|
private Integer pageNum;
|
||||||
|
@ApiModelProperty(value = "每页条数")
|
||||||
|
private Integer pageSize;
|
||||||
|
@ApiModelProperty(value = "总页数")
|
||||||
|
private Integer totalPage;
|
||||||
|
|
||||||
public DocResponseJson() {
|
public DocResponseJson() {
|
||||||
this.errCode = 200;
|
this.errCode = 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DocResponseJson(T data) {
|
public DocResponseJson(Object data) {
|
||||||
this.setData(data);
|
this.setData(data);
|
||||||
this.errCode = 200;
|
this.errCode = 200;
|
||||||
}
|
}
|
||||||
@@ -42,7 +51,7 @@ public class DocResponseJson<T> implements ResponseJson<T> {
|
|||||||
this.errMsg = errMsg;
|
this.errMsg = errMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DocResponseJson(int errCode, String errMsg, T data) {
|
public DocResponseJson(int errCode, String errMsg, Object data) {
|
||||||
super();
|
super();
|
||||||
this.setData(data);
|
this.setData(data);
|
||||||
this.errCode = errCode;
|
this.errCode = errCode;
|
||||||
@@ -69,13 +78,56 @@ public class DocResponseJson<T> implements ResponseJson<T> {
|
|||||||
public void setErrMsg(String errMsg) {
|
public void setErrMsg(String errMsg) {
|
||||||
this.errMsg = errMsg;
|
this.errMsg = errMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T getData() {
|
public Long getTotal() {
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotal(Long total) {
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPageNum() {
|
||||||
|
return pageNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPageNum(Integer pageNum) {
|
||||||
|
this.pageNum = pageNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPageSize() {
|
||||||
|
return pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPageSize(Integer pageSize) {
|
||||||
|
this.pageSize = pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTotalPage() {
|
||||||
|
return totalPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalPage(Integer totalPage) {
|
||||||
|
this.totalPage = totalPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getData() {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(T data) {
|
public void setData(Object data) {
|
||||||
this.data = data;
|
if (null != data) {
|
||||||
|
if (data instanceof PageInfo) {
|
||||||
|
PageInfo<?> pageInfo = (PageInfo<?>) data;
|
||||||
|
this.data = pageInfo.getList();
|
||||||
|
this.total = pageInfo.getTotal();
|
||||||
|
this.pageNum = pageInfo.getPageNum();
|
||||||
|
this.pageSize = pageInfo.getPageSize();
|
||||||
|
this.totalPage = pageInfo.getPages();
|
||||||
|
} else {
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,7 +171,7 @@ public class DocResponseJson<T> implements ResponseJson<T> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static <T> DocResponseJson<T> ok() {
|
public static <T> DocResponseJson<T> ok() {
|
||||||
return new DocResponseJson<T>();
|
return new DocResponseJson<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -129,11 +181,11 @@ public class DocResponseJson<T> implements ResponseJson<T> {
|
|||||||
* @since 2018年8月7日
|
* @since 2018年8月7日
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static <T> DocResponseJson<T> ok(T data) {
|
public static <T> DocResponseJson<T> ok(Object data) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return DocResponseJson.ok();
|
return DocResponseJson.ok();
|
||||||
}
|
}
|
||||||
DocResponseJson<T> responseJson = new DocResponseJson<T>();
|
DocResponseJson<T> responseJson = new DocResponseJson<>();
|
||||||
responseJson.setData(data);
|
responseJson.setData(data);
|
||||||
return responseJson;
|
return responseJson;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.atomikos.icatch.jta.UserTransactionManager;
|
|||||||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.zyplayer.doc.data.repository.support.interceptor.SqlLogInterceptor;
|
import com.zyplayer.doc.data.repository.support.interceptor.SqlLogInterceptor;
|
||||||
import org.apache.ibatis.plugin.Interceptor;
|
import org.apache.ibatis.plugin.Interceptor;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
@@ -27,52 +28,64 @@ import java.util.Properties;
|
|||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class MybatisPlusConfig {
|
public class MybatisPlusConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sql日志
|
* sql日志
|
||||||
**/
|
**/
|
||||||
private static final SqlLogInterceptor SQL_LOG_INTERCEPTOR;
|
private static final SqlLogInterceptor SQL_LOG_INTERCEPTOR;
|
||||||
|
/**
|
||||||
|
* MYSQL 分页
|
||||||
|
**/
|
||||||
|
private static final PageHelper MYSQL_PAGE_HELPER;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SQL_LOG_INTERCEPTOR = new SqlLogInterceptor();
|
{
|
||||||
Properties properties = new Properties();
|
MYSQL_PAGE_HELPER = new PageHelper();
|
||||||
SQL_LOG_INTERCEPTOR.setProperties(properties);
|
Properties properties = new Properties();
|
||||||
|
properties.setProperty("dialect", "mysql");
|
||||||
|
MYSQL_PAGE_HELPER.setProperties(properties);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
SQL_LOG_INTERCEPTOR = new SqlLogInterceptor();
|
||||||
|
Properties properties = new Properties();
|
||||||
|
SQL_LOG_INTERCEPTOR.setProperties(properties);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分布式事务配置
|
* 分布式事务配置
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
static class JTATransactionManagerConfig {
|
static class JTATransactionManagerConfig {
|
||||||
|
|
||||||
@Bean(name = "userTransaction")
|
@Bean(name = "userTransaction")
|
||||||
public UserTransaction userTransaction() throws Throwable {
|
public UserTransaction userTransaction() throws Throwable {
|
||||||
UserTransactionImp userTransactionImp = new UserTransactionImp();
|
UserTransactionImp userTransactionImp = new UserTransactionImp();
|
||||||
userTransactionImp.setTransactionTimeout(300);
|
userTransactionImp.setTransactionTimeout(300);
|
||||||
return userTransactionImp;
|
return userTransactionImp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "atomikosTransactionManager")
|
@Bean(name = "atomikosTransactionManager")
|
||||||
public TransactionManager atomikosTransactionManager() {
|
public TransactionManager atomikosTransactionManager() {
|
||||||
UserTransactionManager userTransactionManager = new UserTransactionManager();
|
UserTransactionManager userTransactionManager = new UserTransactionManager();
|
||||||
userTransactionManager.setForceShutdown(true);
|
userTransactionManager.setForceShutdown(true);
|
||||||
return userTransactionManager;
|
return userTransactionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "transactionManager")
|
@Bean(name = "transactionManager")
|
||||||
public PlatformTransactionManager transactionManager() throws Throwable {
|
public PlatformTransactionManager transactionManager() throws Throwable {
|
||||||
UserTransaction userTransaction = userTransaction();
|
UserTransaction userTransaction = userTransaction();
|
||||||
TransactionManager atomikosTransactionManager = atomikosTransactionManager();
|
TransactionManager atomikosTransactionManager = atomikosTransactionManager();
|
||||||
|
|
||||||
JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(userTransaction, atomikosTransactionManager);
|
JtaTransactionManager jtaTransactionManager = new JtaTransactionManager(userTransaction, atomikosTransactionManager);
|
||||||
jtaTransactionManager.setAllowCustomIsolationLevels(true);
|
jtaTransactionManager.setAllowCustomIsolationLevels(true);
|
||||||
jtaTransactionManager.setGlobalRollbackOnParticipationFailure(true);
|
jtaTransactionManager.setGlobalRollbackOnParticipationFailure(true);
|
||||||
jtaTransactionManager.setDefaultTimeout(30);
|
jtaTransactionManager.setDefaultTimeout(30);
|
||||||
|
|
||||||
return jtaTransactionManager;
|
return jtaTransactionManager;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据库配置
|
* 数据库配置
|
||||||
*/
|
*/
|
||||||
@@ -80,7 +93,7 @@ public class MybatisPlusConfig {
|
|||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@MapperScan(value = "com.zyplayer.doc.data.repository.manage.mapper", sqlSessionFactoryRef = "manageSqlSessionFactory")
|
@MapperScan(value = "com.zyplayer.doc.data.repository.manage.mapper", sqlSessionFactoryRef = "manageSqlSessionFactory")
|
||||||
static class ManageMybatisDbConfig {
|
static class ManageMybatisDbConfig {
|
||||||
|
|
||||||
@Value("${zyplayer.doc.manage.datasource.driverClassName}")
|
@Value("${zyplayer.doc.manage.datasource.driverClassName}")
|
||||||
private String driverClassName;
|
private String driverClassName;
|
||||||
@Value("${zyplayer.doc.manage.datasource.url}")
|
@Value("${zyplayer.doc.manage.datasource.url}")
|
||||||
@@ -89,7 +102,7 @@ public class MybatisPlusConfig {
|
|||||||
private String username;
|
private String username;
|
||||||
@Value("${zyplayer.doc.manage.datasource.password}")
|
@Value("${zyplayer.doc.manage.datasource.password}")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@Bean(name = "manageDatasource")
|
@Bean(name = "manageDatasource")
|
||||||
public DataSource manageDatasource() {
|
public DataSource manageDatasource() {
|
||||||
Properties xaProperties = new Properties();
|
Properties xaProperties = new Properties();
|
||||||
@@ -101,7 +114,7 @@ public class MybatisPlusConfig {
|
|||||||
xaProperties.setProperty("testOnBorrow", "true");
|
xaProperties.setProperty("testOnBorrow", "true");
|
||||||
xaProperties.setProperty("testWhileIdle", "true");
|
xaProperties.setProperty("testWhileIdle", "true");
|
||||||
xaProperties.setProperty("validationQuery", "select 'x'");
|
xaProperties.setProperty("validationQuery", "select 'x'");
|
||||||
|
|
||||||
AtomikosDataSourceBean xaDataSource = new AtomikosDataSourceBean();
|
AtomikosDataSourceBean xaDataSource = new AtomikosDataSourceBean();
|
||||||
xaDataSource.setXaProperties(xaProperties);
|
xaDataSource.setXaProperties(xaProperties);
|
||||||
xaDataSource.setXaDataSourceClassName("com.alibaba.druid.pool.xa.DruidXADataSource");
|
xaDataSource.setXaDataSourceClassName("com.alibaba.druid.pool.xa.DruidXADataSource");
|
||||||
@@ -111,19 +124,19 @@ public class MybatisPlusConfig {
|
|||||||
xaDataSource.setMaxLifetime(60);
|
xaDataSource.setMaxLifetime(60);
|
||||||
return xaDataSource;
|
return xaDataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(name = "manageSqlSessionFactory")
|
@Bean(name = "manageSqlSessionFactory")
|
||||||
public MybatisSqlSessionFactoryBean manageSqlSessionFactory() throws Exception {
|
public MybatisSqlSessionFactoryBean manageSqlSessionFactory() throws Exception {
|
||||||
MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
|
MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
|
||||||
sqlSessionFactoryBean.setDataSource(manageDatasource());
|
sqlSessionFactoryBean.setDataSource(manageDatasource());
|
||||||
sqlSessionFactoryBean.setPlugins(new Interceptor[]{SQL_LOG_INTERCEPTOR});
|
sqlSessionFactoryBean.setPlugins(new Interceptor[]{SQL_LOG_INTERCEPTOR, MYSQL_PAGE_HELPER});
|
||||||
|
|
||||||
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||||
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mapper/manage/*Mapper.xml"));
|
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mapper/manage/*Mapper.xml"));
|
||||||
return sqlSessionFactoryBean;
|
return sqlSessionFactoryBean;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public PerformanceInterceptor performanceInterceptor() {
|
public PerformanceInterceptor performanceInterceptor() {
|
||||||
PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
|
PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
|
||||||
@@ -133,7 +146,7 @@ public class MybatisPlusConfig {
|
|||||||
performanceInterceptor.setFormat(true);
|
performanceInterceptor.setFormat(true);
|
||||||
return performanceInterceptor;
|
return performanceInterceptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public PaginationInterceptor paginationInterceptor() {
|
public PaginationInterceptor paginationInterceptor() {
|
||||||
return new PaginationInterceptor();
|
return new PaginationInterceptor();
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package com.zyplayer.doc.data.repository.manage.entity;
|
package com.zyplayer.doc.data.repository.manage.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import java.util.Date;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -63,6 +64,11 @@ public class WikiPageContent implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预览内容
|
||||||
|
*/
|
||||||
|
private String preview;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -141,4 +147,12 @@ public class WikiPageContent implements Serializable {
|
|||||||
", updateTime=" + updateTime +
|
", updateTime=" + updateTime +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPreview() {
|
||||||
|
return preview;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreview(String preview) {
|
||||||
|
this.preview = preview;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ ALTER TABLE `wiki_page` ADD COLUMN `seq_no` int NOT NULL DEFAULT 0 COMMENT '顺
|
|||||||
-- 初始化seq
|
-- 初始化seq
|
||||||
UPDATE wiki_page SET seq_no=id WHERE del_flag=0;
|
UPDATE wiki_page SET seq_no=id WHERE del_flag=0;
|
||||||
|
|
||||||
|
ALTER TABLE `wiki_page_content` ADD COLUMN `preview` varchar(1024) NULL COMMENT '预览内容';
|
||||||
|
|
||||||
-- 全新的库:
|
-- 全新的库:
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
app.doGetPageList(null);
|
app.doGetPageList(null);
|
||||||
app.$router.push({path: '/home'});
|
app.$router.push({path: '/home', query: {spaceId: data}});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loadSpaceList() {
|
loadSpaceList() {
|
||||||
@@ -294,6 +294,7 @@
|
|||||||
app.nowClickPath = {spaceId: spaceId};
|
app.nowClickPath = {spaceId: spaceId};
|
||||||
app.choiceSpace = spaceId;
|
app.choiceSpace = spaceId;
|
||||||
app.doGetPageList(null);
|
app.doGetPageList(null);
|
||||||
|
app.$router.push({path: '/home', query: {spaceId: spaceId}});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ var URL = {
|
|||||||
pageList: '/zyplayer-doc-wiki/page/list',
|
pageList: '/zyplayer-doc-wiki/page/list',
|
||||||
updatePage: '/zyplayer-doc-wiki/page/update',
|
updatePage: '/zyplayer-doc-wiki/page/update',
|
||||||
pageDetail: '/zyplayer-doc-wiki/page/detail',
|
pageDetail: '/zyplayer-doc-wiki/page/detail',
|
||||||
|
pageNews: '/zyplayer-doc-wiki/page/news',
|
||||||
spaceList: '/zyplayer-doc-wiki/space/list',
|
spaceList: '/zyplayer-doc-wiki/space/list',
|
||||||
updateSpace: '/zyplayer-doc-wiki/space/update',
|
updateSpace: '/zyplayer-doc-wiki/space/update',
|
||||||
getPageUserAuthList: '/zyplayer-doc-wiki/page/auth/list',
|
getPageUserAuthList: '/zyplayer-doc-wiki/page/auth/list',
|
||||||
|
|||||||
@@ -1,39 +1,121 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div style="padding: 10px;">
|
||||||
<div style="margin-top: 30px;color: #666; text-align: center; font-size: 30px;">欢迎使用在线文档</div>
|
<div style="max-width: 800px;margin: 0 auto;">
|
||||||
<div style="margin-top: 30px;color: #666; text-align: center;">
|
<el-select v-model="searchParam.newsType" v-on:change="getSpacePageNews" placeholder="请选择查看方式" style="float: right;z-index: 1;">
|
||||||
{{nowSpaceShow.name}}
|
<el-option :label="val" :value="index+1" v-for="(val, index) in newsTypes"></el-option>
|
||||||
<span v-show="nowSpaceShow.spaceExplain && nowSpaceShow.spaceExplain.length > 0"> · {{nowSpaceShow.spaceExplain}}</span>
|
</el-select>
|
||||||
|
<el-tabs value="first">
|
||||||
|
<el-tab-pane :label="newsTypes[searchParam.newsType-1]" name="first">
|
||||||
|
<div v-if="spacePageNews.length <= 0" class="empty-news">暂无数据</div>
|
||||||
|
<div v-else class="line-box" v-for="item in spacePageNews">
|
||||||
|
<div class="line-title">
|
||||||
|
<span class="text-link">{{item.createUserName}}</span> 发布于 <span class="text-link">{{item.spaceName}}</span>
|
||||||
|
</div>
|
||||||
|
<div class="page-preview-box" v-on:click="showPageDetail(item)">
|
||||||
|
<div class="page-preview-title">{{item.pageTitle}}</div>
|
||||||
|
<div class="page-preview-content">{{item.previewContent}}</div>
|
||||||
|
<div>
|
||||||
|
<span><img src="../../assets/img/zan.png" class="zan-img"> {{item.zanNum}} </span>
|
||||||
|
<span><i class="el-icon-view view-img"></i> {{item.viewNum}} </span>
|
||||||
|
<span>{{item.updateTime||item.createTime}}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
<div class="page-info-box">
|
||||||
|
<el-pagination
|
||||||
|
@size-change="handleSizeChange"
|
||||||
|
@current-change="handleCurrentChange"
|
||||||
|
:page-sizes="[20, 50, 100]"
|
||||||
|
:page-size="20"
|
||||||
|
:current-page="searchParam.pageNum"
|
||||||
|
layout="prev, pager, next, jumper, sizes, total"
|
||||||
|
:total="totalCount"
|
||||||
|
>
|
||||||
|
</el-pagination>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import toast from '../../common/lib/common/toast'
|
||||||
import global from '../../common/config/global'
|
import global from '../../common/config/global'
|
||||||
|
|
||||||
|
var app;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
nowSpaceShow: {
|
totalCount: 0,
|
||||||
name: '',
|
searchParam: {
|
||||||
spaceExplain: '',
|
spaceId: '',
|
||||||
}
|
newsType: 1,
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
},
|
||||||
|
spacePageNews:[],
|
||||||
|
newsTypes:["最近更新", "最新创建", "查看最多", "点赞最多", "查看+点赞最多"],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
beforeRouteUpdate(to, from, next) {
|
||||||
|
this.initQueryParam(to);
|
||||||
|
next();
|
||||||
|
},
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
// this.getUserInfo();
|
this.initQueryParam(this.$route);
|
||||||
|
app = this;
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getUserInfo: function () {
|
getSpacePageNews() {
|
||||||
// this.common.post(this.apilist1.getUserInfo, {}, function (json) {});
|
this.common.post(this.apilist1.pageNews, this.searchParam, function (json) {
|
||||||
|
app.spacePageNews = json.data || [];
|
||||||
|
app.totalCount = json.total;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleSizeChange(val) {
|
||||||
|
this.searchParam.pageSize = val;
|
||||||
|
this.getSpacePageNews();
|
||||||
|
},
|
||||||
|
showPageDetail(row) {
|
||||||
|
this.nowClickPath = {spaceId: row.spaceId, pageId: row.pageId};
|
||||||
|
this.$router.push({path: '/page/show', query: this.nowClickPath});
|
||||||
|
},
|
||||||
|
handleCurrentChange(val) {
|
||||||
|
this.searchParam.pageNum = val;
|
||||||
|
this.getSpacePageNews();
|
||||||
|
},
|
||||||
|
initQueryParam(to) {
|
||||||
|
this.searchParam = {
|
||||||
|
spaceId: to.query.spaceId,
|
||||||
|
newsType: 1,
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
};
|
||||||
|
if (!!this.searchParam.spaceId) {
|
||||||
|
this.getSpacePageNews();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
sendMsgToParent: function () {
|
|
||||||
// global.vue.$app.sendMsgToParent("xxx");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
|
.empty-news{text-align: center;padding: 100px;}
|
||||||
|
|
||||||
|
.text-link {
|
||||||
|
color: #444;
|
||||||
|
/*cursor: pointer;*/
|
||||||
|
/*font-weight: bold;*/
|
||||||
|
}
|
||||||
|
.line-box{color: #666;border-bottom: 1px solid #eee;padding: 20px 0;}
|
||||||
|
.line-title{font-size: 14px;}
|
||||||
|
.page-preview-box{cursor: pointer;}
|
||||||
|
.page-preview-title{font-size: 20px;margin: 10px 0 5px 0;color: #000;}
|
||||||
|
.page-preview-content{font-size: 16px;margin-bottom: 5px;}
|
||||||
|
.zan-img{vertical-align: middle;margin-top: -3px;}
|
||||||
|
.view-img{font-size: 16px;color: #666;}
|
||||||
|
|
||||||
|
.page-info-box{text-align: right;margin: 20px 0 50px 0;}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -63,12 +63,17 @@
|
|||||||
toast.warn("标题不能为空");
|
toast.warn("标题不能为空");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var preview = this.editor.txt.text();
|
||||||
|
if (preview.length > 200) {
|
||||||
|
preview = preview.substring(0, 200) + '...';
|
||||||
|
}
|
||||||
var param = {
|
var param = {
|
||||||
spaceId: app.parentPath.spaceId,
|
spaceId: app.parentPath.spaceId,
|
||||||
parentId: parentId,
|
parentId: parentId,
|
||||||
id: app.wikiPage.id,
|
id: app.wikiPage.id,
|
||||||
name: app.newPageTitle,
|
name: app.newPageTitle,
|
||||||
content: this.editor.txt.html()
|
content: this.editor.txt.html(),
|
||||||
|
preview: preview,
|
||||||
};
|
};
|
||||||
this.common.post(this.apilist1.updatePage, param, function (json) {
|
this.common.post(this.apilist1.updatePage, param, function (json) {
|
||||||
toast.success("保存成功!");
|
toast.success("保存成功!");
|
||||||
|
|||||||
@@ -253,7 +253,7 @@
|
|||||||
this.common.post(this.apilist1.updatePage, param, function (json) {
|
this.common.post(this.apilist1.updatePage, param, function (json) {
|
||||||
// 重新加载左侧列表,跳转到展示页面
|
// 重新加载左侧列表,跳转到展示页面
|
||||||
global.vue.$app.doGetPageList(null);
|
global.vue.$app.doGetPageList(null);
|
||||||
app.$router.push({path: '/home'});
|
app.$router.push({path: '/home', query: {spaceId: app.nowClickPath.spaceId}});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,14 +1,19 @@
|
|||||||
package com.zyplayer.doc.wiki.controller;
|
package com.zyplayer.doc.wiki.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||||
import com.zyplayer.doc.core.json.ResponseJson;
|
import com.zyplayer.doc.core.json.ResponseJson;
|
||||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
|
||||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||||
import com.zyplayer.doc.data.repository.manage.entity.*;
|
import com.zyplayer.doc.data.repository.manage.entity.*;
|
||||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageMapper;
|
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageMapper;
|
||||||
import com.zyplayer.doc.data.service.manage.*;
|
import com.zyplayer.doc.data.service.manage.*;
|
||||||
|
import com.zyplayer.doc.wiki.controller.param.SpaceNewsParam;
|
||||||
|
import com.zyplayer.doc.wiki.controller.vo.SpaceNewsVo;
|
||||||
import com.zyplayer.doc.wiki.controller.vo.WikiPageContentVo;
|
import com.zyplayer.doc.wiki.controller.vo.WikiPageContentVo;
|
||||||
import com.zyplayer.doc.wiki.controller.vo.WikiPageVo;
|
import com.zyplayer.doc.wiki.controller.vo.WikiPageVo;
|
||||||
import com.zyplayer.doc.wiki.framework.consts.SpaceType;
|
import com.zyplayer.doc.wiki.framework.consts.SpaceType;
|
||||||
@@ -150,10 +155,11 @@ public class WikiPageController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public ResponseJson<Object> update(WikiPage wikiPage, String content) {
|
public ResponseJson<Object> update(WikiPage wikiPage, String content, String preview) {
|
||||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||||
WikiPageContent pageContent = new WikiPageContent();
|
WikiPageContent pageContent = new WikiPageContent();
|
||||||
pageContent.setContent(content);
|
pageContent.setContent(content);
|
||||||
|
pageContent.setPreview(preview);
|
||||||
Integer delFlag = Optional.ofNullable(wikiPage.getDelFlag()).orElse(0);
|
Integer delFlag = Optional.ofNullable(wikiPage.getDelFlag()).orElse(0);
|
||||||
if (delFlag == 0 && StringUtils.isBlank(wikiPage.getName())) {
|
if (delFlag == 0 && StringUtils.isBlank(wikiPage.getName())) {
|
||||||
return DocResponseJson.warn("标题不能为空!");
|
return DocResponseJson.warn("标题不能为空!");
|
||||||
@@ -212,6 +218,56 @@ public class WikiPageController {
|
|||||||
return DocResponseJson.ok(wikiPage);
|
return DocResponseJson.ok(wikiPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/news")
|
||||||
|
public ResponseJson<Object> news(SpaceNewsParam param) {
|
||||||
|
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||||
|
// 空间不是自己的
|
||||||
|
Long spaceId = param.getSpaceId();
|
||||||
|
if (spaceId == null || spaceId <= 0) {
|
||||||
|
return DocResponseJson.ok();
|
||||||
|
}
|
||||||
|
WikiSpace wikiSpaceSel = wikiSpaceService.getById(spaceId);
|
||||||
|
if (SpaceType.isOthersPrivate(wikiSpaceSel.getType(), currentUser.getUserId(), wikiSpaceSel.getCreateUserId())) {
|
||||||
|
return DocResponseJson.ok();
|
||||||
|
}
|
||||||
|
QueryWrapper<WikiPage> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq("space_id", spaceId);
|
||||||
|
wrapper.eq("del_flag", 0);
|
||||||
|
wrapper.orderByDesc(param.getNewsType() == 1, "update_time");
|
||||||
|
wrapper.orderByDesc(param.getNewsType() == 2, "create_time");
|
||||||
|
wrapper.orderByDesc(param.getNewsType() == 3, "view_num");
|
||||||
|
wrapper.orderByDesc(param.getNewsType() == 4, "zan_num");
|
||||||
|
wrapper.orderByDesc(param.getNewsType() == 5, "view_num+zan_num");
|
||||||
|
// 分页查询
|
||||||
|
PageHelper.startPage(param.getPageNum(), param.getPageSize(), true);
|
||||||
|
List<WikiPage> pageList = wikiPageService.list(wrapper);
|
||||||
|
PageInfo<WikiPage> pageListPageInfo = new PageInfo<>(pageList);
|
||||||
|
if (pageList == null || pageList.isEmpty()) {
|
||||||
|
return DocResponseJson.ok(pageListPageInfo);
|
||||||
|
}
|
||||||
|
List<Long> pageIds = pageList.stream().map(WikiPage::getId).collect(Collectors.toList());
|
||||||
|
QueryWrapper<WikiPageContent> contentWrapper = new QueryWrapper<>();
|
||||||
|
contentWrapper.in("page_id", pageIds);
|
||||||
|
contentWrapper.select("page_id", "preview");
|
||||||
|
List<WikiPageContent> pageContentList = wikiPageContentService.list(contentWrapper);
|
||||||
|
Map<Long, String> contentMap = pageContentList.stream()
|
||||||
|
.filter(val -> val.getPreview() != null)
|
||||||
|
.collect(Collectors.toMap(WikiPageContent::getPageId, WikiPageContent::getPreview));
|
||||||
|
|
||||||
|
List<SpaceNewsVo> pageVoList = new LinkedList<>();
|
||||||
|
pageList.forEach(val -> {
|
||||||
|
SpaceNewsVo spaceNewsVo = mapper.map(val, SpaceNewsVo.class);
|
||||||
|
spaceNewsVo.setSpaceName(wikiSpaceSel.getName());
|
||||||
|
spaceNewsVo.setPreviewContent(contentMap.get(val.getId()));
|
||||||
|
spaceNewsVo.setPageTitle(val.getName());
|
||||||
|
spaceNewsVo.setPageId(val.getId());
|
||||||
|
pageVoList.add(spaceNewsVo);
|
||||||
|
});
|
||||||
|
DocResponseJson<Object> responseJson = DocResponseJson.ok(pageListPageInfo);
|
||||||
|
responseJson.setData(pageVoList);
|
||||||
|
return responseJson;
|
||||||
|
}
|
||||||
|
|
||||||
private void setChildren(Map<Long, List<WikiPageVo>> listMap, List<WikiPageVo> nodePageList, String path) {
|
private void setChildren(Map<Long, List<WikiPageVo>> listMap, List<WikiPageVo> nodePageList, String path) {
|
||||||
if (nodePageList == null || listMap == null) {
|
if (nodePageList == null || listMap == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.zyplayer.doc.wiki.controller.param;
|
||||||
|
|
||||||
|
public class SpaceNewsParam {
|
||||||
|
private Long spaceId;
|
||||||
|
private Integer newsType;
|
||||||
|
private Integer pageNum;
|
||||||
|
private Integer pageSize;
|
||||||
|
|
||||||
|
public Integer getPageNum() {
|
||||||
|
return pageNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPageNum(Integer pageNum) {
|
||||||
|
this.pageNum = pageNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPageSize() {
|
||||||
|
return pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPageSize(Integer pageSize) {
|
||||||
|
this.pageSize = pageSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSpaceId() {
|
||||||
|
return spaceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpaceId(Long spaceId) {
|
||||||
|
this.spaceId = spaceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNewsType() {
|
||||||
|
return newsType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNewsType(Integer newsType) {
|
||||||
|
this.newsType = newsType;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
package com.zyplayer.doc.wiki.controller.vo;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class SpaceNewsVo {
|
||||||
|
private Long spaceId;
|
||||||
|
private Long pageId;
|
||||||
|
private Integer zanNum;
|
||||||
|
private Integer viewNum;
|
||||||
|
private String createUserName;
|
||||||
|
private String updateUserName;
|
||||||
|
private Date createTime;
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
private String spaceName;
|
||||||
|
private String pageTitle;
|
||||||
|
private String previewContent;
|
||||||
|
|
||||||
|
public Long getPageId() {
|
||||||
|
return pageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPageId(Long pageId) {
|
||||||
|
this.pageId = pageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getZanNum() {
|
||||||
|
return zanNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZanNum(Integer zanNum) {
|
||||||
|
this.zanNum = zanNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getViewNum() {
|
||||||
|
return viewNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setViewNum(Integer viewNum) {
|
||||||
|
this.viewNum = viewNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreateUserName() {
|
||||||
|
return createUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateUserName(String createUserName) {
|
||||||
|
this.createUserName = createUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUpdateUserName() {
|
||||||
|
return updateUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateUserName(String updateUserName) {
|
||||||
|
this.updateUserName = updateUserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(Date updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSpaceName() {
|
||||||
|
return spaceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpaceName(String spaceName) {
|
||||||
|
this.spaceName = spaceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPageTitle() {
|
||||||
|
return pageTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPageTitle(String pageTitle) {
|
||||||
|
this.pageTitle = pageTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPreviewContent() {
|
||||||
|
return previewContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPreviewContent(String previewContent) {
|
||||||
|
this.previewContent = previewContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSpaceId() {
|
||||||
|
return spaceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpaceId(Long spaceId) {
|
||||||
|
this.spaceId = spaceId;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user