wiki优化
This commit is contained in:
@@ -12,7 +12,7 @@ import java.util.Date;
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2019-02-24
|
* @since 2019-03-05
|
||||||
*/
|
*/
|
||||||
public class WikiPage implements Serializable {
|
public class WikiPage implements Serializable {
|
||||||
|
|
||||||
@@ -44,6 +44,11 @@ public class WikiPage implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Integer nodeType;
|
private Integer nodeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 赞的数量
|
||||||
|
*/
|
||||||
|
private Integer zanNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建人ID
|
* 创建人ID
|
||||||
*/
|
*/
|
||||||
@@ -114,6 +119,13 @@ public class WikiPage implements Serializable {
|
|||||||
public void setNodeType(Integer nodeType) {
|
public void setNodeType(Integer nodeType) {
|
||||||
this.nodeType = nodeType;
|
this.nodeType = nodeType;
|
||||||
}
|
}
|
||||||
|
public Integer getZanNum() {
|
||||||
|
return zanNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZanNum(Integer zanNum) {
|
||||||
|
this.zanNum = zanNum;
|
||||||
|
}
|
||||||
public Long getCreateUserId() {
|
public Long getCreateUserId() {
|
||||||
return createUserId;
|
return createUserId;
|
||||||
}
|
}
|
||||||
@@ -172,6 +184,7 @@ public class WikiPage implements Serializable {
|
|||||||
", name=" + name +
|
", name=" + name +
|
||||||
", parentId=" + parentId +
|
", parentId=" + parentId +
|
||||||
", nodeType=" + nodeType +
|
", nodeType=" + nodeType +
|
||||||
|
", zanNum=" + zanNum +
|
||||||
", createUserId=" + createUserId +
|
", createUserId=" + createUserId +
|
||||||
", createUserName=" + createUserName +
|
", createUserName=" + createUserName +
|
||||||
", createTime=" + createTime +
|
", createTime=" + createTime +
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -11,7 +12,7 @@ import java.io.Serializable;
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2019-02-24
|
* @since 2019-03-05
|
||||||
*/
|
*/
|
||||||
public class WikiPageZan implements Serializable {
|
public class WikiPageZan implements Serializable {
|
||||||
|
|
||||||
@@ -48,6 +49,11 @@ public class WikiPageZan implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否有效 0=无效 1=有效
|
||||||
|
*/
|
||||||
|
private Integer yn;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -90,6 +96,13 @@ public class WikiPageZan implements Serializable {
|
|||||||
public void setCreateTime(Date createTime) {
|
public void setCreateTime(Date createTime) {
|
||||||
this.createTime = createTime;
|
this.createTime = createTime;
|
||||||
}
|
}
|
||||||
|
public Integer getYn() {
|
||||||
|
return yn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setYn(Integer yn) {
|
||||||
|
this.yn = yn;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@@ -100,6 +113,7 @@ public class WikiPageZan implements Serializable {
|
|||||||
", createUserId=" + createUserId +
|
", createUserId=" + createUserId +
|
||||||
", createUserName=" + createUserName +
|
", createUserName=" + createUserName +
|
||||||
", createTime=" + createTime +
|
", createTime=" + createTime +
|
||||||
|
", yn=" + yn +
|
||||||
"}";
|
"}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||||
|
|
||||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPage;
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.zyplayer.doc.data.repository.manage.entity.WikiPage;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -9,8 +11,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2019-02-24
|
* @since 2019-03-05
|
||||||
*/
|
*/
|
||||||
public interface WikiPageMapper extends BaseMapper<WikiPage> {
|
public interface WikiPageMapper extends BaseMapper<WikiPage> {
|
||||||
|
|
||||||
|
@Update("update wiki_page set zan_num=zan_num + #{numAdd} where id=#{id}")
|
||||||
|
void updateZanNum(@Param("id") Long id, @Param("numAdd") Integer numAdd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.zyplayer.doc.data.repository.manage.mapper;
|
|||||||
|
|
||||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageZan;
|
import com.zyplayer.doc.data.repository.manage.entity.WikiPageZan;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -9,7 +11,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2019-02-24
|
* @since 2019-03-05
|
||||||
*/
|
*/
|
||||||
public interface WikiPageZanMapper extends BaseMapper<WikiPageZan> {
|
public interface WikiPageZanMapper extends BaseMapper<WikiPageZan> {
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ public class CodeGenerator {
|
|||||||
|
|
||||||
final String moduleName = "manage";
|
final String moduleName = "manage";
|
||||||
// final String[] tableName = { "zyplayer_storage", "auth_info", "user_auth", "user_info" };
|
// final String[] tableName = { "zyplayer_storage", "auth_info", "user_auth", "user_info" };
|
||||||
final String[] tableName = { "wiki_space", "wiki_page", "wiki_page_content", "wiki_page_file", "wiki_page_comment", "wiki_page_zan" };
|
// final String[] tableName = { "wiki_space", "wiki_page", "wiki_page_content", "wiki_page_file", "wiki_page_comment", "wiki_page_zan" };
|
||||||
// final String[] tableName = { "wiki_page" };
|
final String[] tableName = { "wiki_page" };
|
||||||
|
|
||||||
// 代码生成器
|
// 代码生成器
|
||||||
AutoGenerator mpg = new AutoGenerator();
|
AutoGenerator mpg = new AutoGenerator();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2019-02-24
|
* @since 2019-03-05
|
||||||
*/
|
*/
|
||||||
public interface WikiPageService extends IService<WikiPage> {
|
public interface WikiPageService extends IService<WikiPage> {
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2019-02-24
|
* @since 2019-03-05
|
||||||
*/
|
*/
|
||||||
public interface WikiPageZanService extends IService<WikiPageZan> {
|
public interface WikiPageZanService extends IService<WikiPageZan> {
|
||||||
|
void zanPage(WikiPageZan wikiPageZan);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2019-02-24
|
* @since 2019-03-05
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class WikiPageServiceImpl extends ServiceImpl<WikiPageMapper, WikiPage> implements WikiPageService {
|
public class WikiPageServiceImpl extends ServiceImpl<WikiPageMapper, WikiPage> implements WikiPageService {
|
||||||
|
|||||||
@@ -1,10 +1,19 @@
|
|||||||
package com.zyplayer.doc.data.service.manage.impl;
|
package com.zyplayer.doc.data.service.manage.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||||
|
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageZan;
|
import com.zyplayer.doc.data.repository.manage.entity.WikiPageZan;
|
||||||
|
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageMapper;
|
||||||
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageZanMapper;
|
import com.zyplayer.doc.data.repository.manage.mapper.WikiPageZanMapper;
|
||||||
import com.zyplayer.doc.data.service.manage.WikiPageZanService;
|
import com.zyplayer.doc.data.service.manage.WikiPageZanService;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -12,9 +21,35 @@ import org.springframework.stereotype.Service;
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author 暮光:城中城
|
* @author 暮光:城中城
|
||||||
* @since 2019-02-24
|
* @since 2019-03-05
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class WikiPageZanServiceImpl extends ServiceImpl<WikiPageZanMapper, WikiPageZan> implements WikiPageZanService {
|
public class WikiPageZanServiceImpl extends ServiceImpl<WikiPageZanMapper, WikiPageZan> implements WikiPageZanService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
WikiPageMapper wikiPageMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void zanPage(WikiPageZan wikiPageZan) {
|
||||||
|
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||||
|
UpdateWrapper<WikiPageZan> wrapper = new UpdateWrapper<>();
|
||||||
|
wrapper.eq("create_user_id", currentUser.getUserId());
|
||||||
|
wrapper.eq("page_id", wikiPageZan.getPageId());
|
||||||
|
wrapper.eq(wikiPageZan.getCommentId() != null, "comment_id", wikiPageZan.getCommentId());
|
||||||
|
WikiPageZan pageZan = this.getOne(wrapper);
|
||||||
|
if (pageZan != null) {
|
||||||
|
if (Objects.equals(wikiPageZan.getYn(), pageZan.getYn())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wikiPageZan.setId(pageZan.getId());
|
||||||
|
this.updateById(wikiPageZan);
|
||||||
|
} else {
|
||||||
|
wikiPageZan.setCreateTime(new Date());
|
||||||
|
wikiPageZan.setCreateUserId(currentUser.getUserId());
|
||||||
|
this.save(wikiPageZan);
|
||||||
|
}
|
||||||
|
int numAdd = wikiPageZan.getYn() == 1 ? 1 : -1;
|
||||||
|
wikiPageMapper.updateZanNum(wikiPageZan.getPageId(), numAdd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,13 +27,10 @@ import org.apache.dubbo.rpc.service.GenericService;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
import javax.annotation.PreDestroy;
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Parameter;
|
import java.lang.reflect.Parameter;
|
||||||
@@ -73,14 +70,22 @@ public class DubboController {
|
|||||||
private CuratorFramework serverClient;
|
private CuratorFramework serverClient;
|
||||||
private CuratorFramework metadataClient;
|
private CuratorFramework metadataClient;
|
||||||
|
|
||||||
@PostConstruct
|
private void initServerClient() {
|
||||||
private void init() {
|
if (serverClient == null && StringUtils.isNotBlank(serviceZookeeperUrl)) {
|
||||||
if (StringUtils.isNotBlank(serviceZookeeperUrl)) {
|
synchronized (DEFAULT_ROOT) {
|
||||||
|
if (serverClient == null) {
|
||||||
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
|
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
|
||||||
serverClient = CuratorFrameworkFactory.newClient(serviceZookeeperUrl, retryPolicy);
|
serverClient = CuratorFrameworkFactory.newClient(serviceZookeeperUrl, retryPolicy);
|
||||||
serverClient.start();
|
serverClient.start();
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(metadataZookeeperUrl)) {
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initMetadataClient() {
|
||||||
|
if (metadataClient == null && StringUtils.isNotBlank(metadataZookeeperUrl)) {
|
||||||
|
synchronized (DEFAULT_ROOT) {
|
||||||
|
if (metadataClient == null) {
|
||||||
URL url = UrlUtils.parseURL(metadataZookeeperUrl, Collections.emptyMap());
|
URL url = UrlUtils.parseURL(metadataZookeeperUrl, Collections.emptyMap());
|
||||||
String group = url.getParameter(Constants.GROUP_KEY, DEFAULT_ROOT);
|
String group = url.getParameter(Constants.GROUP_KEY, DEFAULT_ROOT);
|
||||||
if (!group.startsWith(Constants.PATH_SEPARATOR)) {
|
if (!group.startsWith(Constants.PATH_SEPARATOR)) {
|
||||||
@@ -92,10 +97,7 @@ public class DubboController {
|
|||||||
metadataClient.start();
|
metadataClient.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@PreDestroy
|
|
||||||
private void preDestroy() {
|
|
||||||
serverClient.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -205,23 +207,6 @@ public class DubboController {
|
|||||||
return DocResponseJson.ok(dubboInfoVo);
|
return DocResponseJson.ok(dubboInfoVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取文档详情,依据类名生成
|
|
||||||
*
|
|
||||||
* @author 暮光:城中城
|
|
||||||
* @since 2019年2月10日
|
|
||||||
**/
|
|
||||||
@GetMapping(value = "/test")
|
|
||||||
public DocResponseJson test() throws Exception {
|
|
||||||
String path = getNodePath("com.zyplayer.dubbo.service.UserService", null, null, "dubbo-provider");
|
|
||||||
if (metadataClient.checkExists().forPath(path) == null) {
|
|
||||||
return DocResponseJson.ok(path);
|
|
||||||
}
|
|
||||||
String metadata = new String(metadataClient.getData().forPath(path));
|
|
||||||
FullServiceDefinition fullServiceDefinition = JSON.parseObject(metadata, FullServiceDefinition.class);
|
|
||||||
return DocResponseJson.ok(fullServiceDefinition);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文档详情,依据类名生成
|
* 获取文档详情,依据类名生成
|
||||||
*
|
*
|
||||||
@@ -341,6 +326,7 @@ public class DubboController {
|
|||||||
* @since 2019年2月10日
|
* @since 2019年2月10日
|
||||||
**/
|
**/
|
||||||
private List<DubboInfo> getDubboInfoByZookeeper() throws Exception {
|
private List<DubboInfo> getDubboInfoByZookeeper() throws Exception {
|
||||||
|
this.initServerClient();
|
||||||
List<String> dubboList = serverClient.getChildren().forPath("/dubbo");
|
List<String> dubboList = serverClient.getChildren().forPath("/dubbo");
|
||||||
if (dubboList == null || dubboList.isEmpty()) {
|
if (dubboList == null || dubboList.isEmpty()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
@@ -348,7 +334,7 @@ public class DubboController {
|
|||||||
List<DubboInfo> providerList = new LinkedList<>();
|
List<DubboInfo> providerList = new LinkedList<>();
|
||||||
for (String dubboStr : dubboList) {
|
for (String dubboStr : dubboList) {
|
||||||
String path = "/dubbo/" + dubboStr + "/providers";
|
String path = "/dubbo/" + dubboStr + "/providers";
|
||||||
if (metadataClient.checkExists().forPath(path) == null) {
|
if (serverClient.checkExists().forPath(path) == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
List<String> providers = serverClient.getChildren().forPath(path);
|
List<String> providers = serverClient.getChildren().forPath(path);
|
||||||
@@ -389,6 +375,7 @@ public class DubboController {
|
|||||||
|
|
||||||
private DubboDocInfo getDefinitionByMetadata(DubboRequestParam param) {
|
private DubboDocInfo getDefinitionByMetadata(DubboRequestParam param) {
|
||||||
try {
|
try {
|
||||||
|
this.initMetadataClient();
|
||||||
String path = getNodePath(param.getService(), null, null, param.getApplication());
|
String path = getNodePath(param.getService(), null, null, param.getApplication());
|
||||||
if (metadataClient.checkExists().forPath(path) == null) {
|
if (metadataClient.checkExists().forPath(path) == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -3,17 +3,16 @@ spring:
|
|||||||
name: zyplayer-doc-manage
|
name: zyplayer-doc-manage
|
||||||
# mvc:
|
# mvc:
|
||||||
# static-path-pattern: /**
|
# static-path-pattern: /**
|
||||||
|
servlet:
|
||||||
|
multipart:
|
||||||
|
max-file-size: 100MB
|
||||||
|
max-request-size: 100MB
|
||||||
|
|
||||||
server:
|
server:
|
||||||
port: 8082
|
port: 8082
|
||||||
servlet:
|
servlet:
|
||||||
context-path: /zyplayer-doc-manage
|
context-path: /zyplayer-doc-manage
|
||||||
|
|
||||||
multipart:
|
|
||||||
enabled: true
|
|
||||||
max-file-size: 100MB
|
|
||||||
max-request-size: 100MB
|
|
||||||
|
|
||||||
zyplayer:
|
zyplayer:
|
||||||
doc:
|
doc:
|
||||||
# dubbo相关配置
|
# dubbo相关配置
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package com.zyplayer.doc.test;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
|
||||||
|
public class MediaTypeTest {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
// MediaType xx = MediaType.parseMediaType("png");
|
||||||
|
// System.out.println(xx.getSubtype());
|
||||||
|
File file = new File("e:/tmp/wikiFiles/2019/03/04/dcf4b4357d5a454180cf54a5d8a2f868.jpg");
|
||||||
|
// String path = file.get
|
||||||
|
|
||||||
|
String contentType = Files.probeContentType(file.toPath());
|
||||||
|
System.out.println(contentType);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -11,14 +11,17 @@ import com.zyplayer.doc.data.service.manage.WikiPageFileService;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -41,30 +44,67 @@ public class WikiCommonController {
|
|||||||
@PostMapping("/upload")
|
@PostMapping("/upload")
|
||||||
public ResponseJson<Object> upload(WikiPageFile wikiPageFile, @RequestParam("files") MultipartFile file) {
|
public ResponseJson<Object> upload(WikiPageFile wikiPageFile, @RequestParam("files") MultipartFile file) {
|
||||||
//通过CommonsMultipartFile的方法直接写文件(注意这个时候)
|
//通过CommonsMultipartFile的方法直接写文件(注意这个时候)
|
||||||
try {
|
|
||||||
String fileName = file.getOriginalFilename();
|
String fileName = file.getOriginalFilename();
|
||||||
String fileSuffix = fileName.substring(fileName.lastIndexOf("."));
|
String fileSuffix = "";
|
||||||
|
if (fileName != null && fileName.lastIndexOf(".") >= 0) {
|
||||||
|
fileSuffix = fileName.substring(fileName.lastIndexOf("."));
|
||||||
|
}
|
||||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||||
String path = uploadPath + "/" + DateTime.now().toString("yyyy/MM/dd") + "/";
|
String path = uploadPath + "/" + DateTime.now().toString("yyyy/MM/dd") + "/";
|
||||||
File newFile = new File(path);
|
File newFile = new File(path);
|
||||||
if (!newFile.exists()) {
|
if (!newFile.exists() && !newFile.mkdir()) {
|
||||||
newFile.mkdir();
|
return DocResponseJson.warn("创建文件夹失败");
|
||||||
}
|
}
|
||||||
path += RandomUtil.simpleUUID() + fileSuffix;
|
path += RandomUtil.simpleUUID() + fileSuffix;
|
||||||
newFile = new File(path);
|
newFile = new File(path);
|
||||||
|
try {
|
||||||
file.transferTo(newFile);
|
file.transferTo(newFile);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return DocResponseJson.warn("保存文件失败");
|
||||||
|
}
|
||||||
wikiPageFile.setFileUrl(path);
|
wikiPageFile.setFileUrl(path);
|
||||||
wikiPageFile.setFileName(fileName);
|
wikiPageFile.setFileName(fileName);
|
||||||
wikiPageFile.setCreateTime(new Date());
|
wikiPageFile.setCreateTime(new Date());
|
||||||
wikiPageFile.setCreateUserId(currentUser.getUserId());
|
wikiPageFile.setCreateUserId(currentUser.getUserId());
|
||||||
wikiPageFile.setCreateUserName(currentUser.getUsername());
|
wikiPageFile.setCreateUserName(currentUser.getUsername());
|
||||||
wikiPageFile.setDelFlag(0);
|
wikiPageFile.setDelFlag(0);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return DocResponseJson.warn("失败");
|
|
||||||
}
|
|
||||||
wikiPageFileService.save(wikiPageFile);
|
wikiPageFileService.save(wikiPageFile);
|
||||||
|
wikiPageFile.setFileUrl("zyplayer-doc-wiki/common/file?fileId=" + wikiPageFile.getId());
|
||||||
return DocResponseJson.ok(wikiPageFile);
|
return DocResponseJson.ok(wikiPageFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/file")
|
||||||
|
public ResponseJson<Object> file(Long fileId, HttpServletResponse response) {
|
||||||
|
if (fileId == null || fileId <= 0) {
|
||||||
|
return DocResponseJson.warn("请指定文件ID");
|
||||||
|
}
|
||||||
|
WikiPageFile pageFile = wikiPageFileService.getById(fileId);
|
||||||
|
if (pageFile == null) {
|
||||||
|
return DocResponseJson.warn("未找到指定文件");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String fileName = pageFile.getFileName();
|
||||||
|
File file = new File(pageFile.getFileUrl());
|
||||||
|
String contentType = Files.probeContentType(file.toPath());
|
||||||
|
response.setContentType(contentType);
|
||||||
|
response.setHeader("Content-disposition", "inline;filename=" + URLEncoder.encode(fileName, "UTF-8"));
|
||||||
|
// response.setHeader("Content-disposition", "inline;filename=" + fileName);
|
||||||
|
// response.setHeader("Content-Disposition", "inline; fileName=" + fileName + ";filename*=utf-8''" + URLEncoder.encode(fileName, "UTF-8"));
|
||||||
|
InputStream inputStream = new FileInputStream(file);
|
||||||
|
OutputStream os = response.getOutputStream();
|
||||||
|
byte[] b = new byte[2048];
|
||||||
|
int length;
|
||||||
|
while ((length = inputStream.read(b)) > 0) {
|
||||||
|
os.write(b, 0, length);
|
||||||
|
}
|
||||||
|
os.close();
|
||||||
|
inputStream.close();
|
||||||
|
return null;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.info("失败:{}", e.getMessage());
|
||||||
|
}
|
||||||
|
return DocResponseJson.warn("获取文件失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ import com.zyplayer.doc.data.config.security.DocUserUtil;
|
|||||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPage;
|
import com.zyplayer.doc.data.repository.manage.entity.WikiPage;
|
||||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageContent;
|
import com.zyplayer.doc.data.repository.manage.entity.WikiPageContent;
|
||||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageFile;
|
import com.zyplayer.doc.data.repository.manage.entity.WikiPageFile;
|
||||||
|
import com.zyplayer.doc.data.repository.manage.entity.WikiPageZan;
|
||||||
import com.zyplayer.doc.data.service.manage.WikiPageContentService;
|
import com.zyplayer.doc.data.service.manage.WikiPageContentService;
|
||||||
import com.zyplayer.doc.data.service.manage.WikiPageFileService;
|
import com.zyplayer.doc.data.service.manage.WikiPageFileService;
|
||||||
import com.zyplayer.doc.data.service.manage.WikiPageService;
|
import com.zyplayer.doc.data.service.manage.WikiPageService;
|
||||||
|
import com.zyplayer.doc.data.service.manage.WikiPageZanService;
|
||||||
import com.zyplayer.doc.wiki.controller.vo.WikiPageContentVo;
|
import com.zyplayer.doc.wiki.controller.vo.WikiPageContentVo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -39,6 +41,8 @@ public class WikiPageController {
|
|||||||
WikiPageContentService wikiPageContentService;
|
WikiPageContentService wikiPageContentService;
|
||||||
@Resource
|
@Resource
|
||||||
WikiPageFileService wikiPageFileService;
|
WikiPageFileService wikiPageFileService;
|
||||||
|
@Resource
|
||||||
|
WikiPageZanService wikiPageZanService;
|
||||||
|
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public ResponseJson<List<WikiPage>> list(WikiPage wikiPage) {
|
public ResponseJson<List<WikiPage>> list(WikiPage wikiPage) {
|
||||||
@@ -54,21 +58,31 @@ public class WikiPageController {
|
|||||||
|
|
||||||
@PostMapping("/detail")
|
@PostMapping("/detail")
|
||||||
public ResponseJson<WikiPageContentVo> detail(WikiPage wikiPage) {
|
public ResponseJson<WikiPageContentVo> detail(WikiPage wikiPage) {
|
||||||
|
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||||
WikiPage wikiPageSel = wikiPageService.getById(wikiPage.getId());
|
WikiPage wikiPageSel = wikiPageService.getById(wikiPage.getId());
|
||||||
|
|
||||||
UpdateWrapper<WikiPageContent> wrapper = new UpdateWrapper<>();
|
UpdateWrapper<WikiPageContent> wrapper = new UpdateWrapper<>();
|
||||||
wrapper.eq("page_id", wikiPage.getId());
|
wrapper.eq("page_id", wikiPage.getId());
|
||||||
WikiPageContent pageContent = wikiPageContentService.getOne(wrapper);
|
WikiPageContent pageContent = wikiPageContentService.getOne(wrapper);
|
||||||
|
|
||||||
|
// TODO 检查space是否开放访问
|
||||||
UpdateWrapper<WikiPageFile> wrapperFile = new UpdateWrapper<>();
|
UpdateWrapper<WikiPageFile> wrapperFile = new UpdateWrapper<>();
|
||||||
wrapperFile.eq("page_id", wikiPage.getId());
|
wrapperFile.eq("page_id", wikiPage.getId());
|
||||||
wrapper.eq("del_flag", 0);
|
wrapperFile.eq("del_flag", 0);
|
||||||
List<WikiPageFile> pageFiles = wikiPageFileService.list(wrapperFile);
|
List<WikiPageFile> pageFiles = wikiPageFileService.list(wrapperFile);
|
||||||
|
for (WikiPageFile pageFile : pageFiles) {
|
||||||
|
pageFile.setFileUrl("zyplayer-doc-wiki/common/file?fileId=" + pageFile.getId());
|
||||||
|
}
|
||||||
|
UpdateWrapper<WikiPageZan> wrapperZan = new UpdateWrapper<>();
|
||||||
|
wrapperZan.eq("page_id", wikiPage.getId());
|
||||||
|
wrapperZan.eq("create_user_id", currentUser.getUserId());
|
||||||
|
wrapperZan.eq("yn", 1);
|
||||||
|
WikiPageZan pageZan = wikiPageZanService.getOne(wrapperZan);
|
||||||
WikiPageContentVo vo = new WikiPageContentVo();
|
WikiPageContentVo vo = new WikiPageContentVo();
|
||||||
vo.setWikiPage(wikiPageSel);
|
vo.setWikiPage(wikiPageSel);
|
||||||
vo.setPageContent(pageContent);
|
vo.setPageContent(pageContent);
|
||||||
vo.setFileList(pageFiles);
|
vo.setFileList(pageFiles);
|
||||||
|
vo.setSelfZan((pageZan != null) ? 1 : 0);
|
||||||
return DocResponseJson.ok(vo);
|
return DocResponseJson.ok(vo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,12 @@
|
|||||||
package com.zyplayer.doc.wiki.controller;
|
package com.zyplayer.doc.wiki.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
||||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
|
||||||
import com.zyplayer.doc.core.json.ResponseJson;
|
|
||||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
|
||||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
|
||||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageFile;
|
|
||||||
import com.zyplayer.doc.data.service.manage.WikiPageFileService;
|
import com.zyplayer.doc.data.service.manage.WikiPageFileService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文档控制器
|
* 文档控制器
|
||||||
@@ -31,28 +22,31 @@ public class WikiPageFileController {
|
|||||||
@Resource
|
@Resource
|
||||||
WikiPageFileService wikiPageFileService;
|
WikiPageFileService wikiPageFileService;
|
||||||
|
|
||||||
@PostMapping("/list")
|
// @PostMapping("/list")
|
||||||
public ResponseJson<List<WikiPageFile>> list(WikiPageFile wikiPageFile) {
|
// public ResponseJson<List<WikiPageFile>> list(WikiPageFile wikiPageFile) {
|
||||||
// TODO 检查space是否开放访问
|
// // TODO 检查space是否开放访问
|
||||||
UpdateWrapper<WikiPageFile> wrapper = new UpdateWrapper<>();
|
// UpdateWrapper<WikiPageFile> wrapper = new UpdateWrapper<>();
|
||||||
wrapper.eq("del_flag", 0);
|
// wrapper.eq("del_flag", 0);
|
||||||
wrapper.eq("page_id", wikiPageFile.getPageId());
|
// wrapper.eq("page_id", wikiPageFile.getPageId());
|
||||||
List<WikiPageFile> fileList = wikiPageFileService.list(wrapper);
|
// List<WikiPageFile> fileList = wikiPageFileService.list(wrapper);
|
||||||
return DocResponseJson.ok(fileList);
|
// for (WikiPageFile pageFile : fileList) {
|
||||||
}
|
// pageFile.setFileUrl("zyplayer-doc-wiki/common/file?fileId=" + pageFile.getId());
|
||||||
|
// }
|
||||||
@PostMapping("/update")
|
// return DocResponseJson.ok(fileList);
|
||||||
public ResponseJson<Object> update(WikiPageFile wikiPageFile) {
|
// }
|
||||||
Long id = wikiPageFile.getId();
|
//
|
||||||
if (id != null && id > 0) {
|
// @PostMapping("/update")
|
||||||
wikiPageFileService.updateById(wikiPageFile);
|
// public ResponseJson<Object> update(WikiPageFile wikiPageFile) {
|
||||||
} else {
|
// Long id = wikiPageFile.getId();
|
||||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
// if (id != null && id > 0) {
|
||||||
wikiPageFile.setCreateTime(new Date());
|
// wikiPageFileService.updateById(wikiPageFile);
|
||||||
wikiPageFile.setCreateUserId(currentUser.getUserId());
|
// } else {
|
||||||
wikiPageFileService.save(wikiPageFile);
|
// DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||||
}
|
// wikiPageFile.setCreateTime(new Date());
|
||||||
return DocResponseJson.ok();
|
// wikiPageFile.setCreateUserId(currentUser.getUserId());
|
||||||
}
|
// wikiPageFileService.save(wikiPageFile);
|
||||||
|
// }
|
||||||
|
// return DocResponseJson.ok();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package com.zyplayer.doc.wiki.controller;
|
package com.zyplayer.doc.wiki.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
||||||
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.data.config.security.DocUserDetails;
|
|
||||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
|
||||||
import com.zyplayer.doc.data.repository.manage.entity.WikiPageZan;
|
import com.zyplayer.doc.data.repository.manage.entity.WikiPageZan;
|
||||||
import com.zyplayer.doc.data.service.manage.WikiPageZanService;
|
import com.zyplayer.doc.data.service.manage.WikiPageZanService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -14,8 +11,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文档控制器
|
* 文档控制器
|
||||||
@@ -31,29 +26,18 @@ public class WikiPageZanController {
|
|||||||
@Resource
|
@Resource
|
||||||
WikiPageZanService wikiPageZanService;
|
WikiPageZanService wikiPageZanService;
|
||||||
|
|
||||||
@PostMapping("/list")
|
// @PostMapping("/list")
|
||||||
public ResponseJson<List<WikiPageZan>> list(WikiPageZan wikiPageZan) {
|
// public ResponseJson<List<WikiPageZan>> list(WikiPageZan wikiPageZan) {
|
||||||
UpdateWrapper<WikiPageZan> wrapper = new UpdateWrapper<>();
|
// UpdateWrapper<WikiPageZan> wrapper = new UpdateWrapper<>();
|
||||||
wrapper.eq("page_id", wikiPageZan.getPageId());
|
// wrapper.eq("page_id", wikiPageZan.getPageId());
|
||||||
wrapper.eq(wikiPageZan.getCommentId() != null, "comment_id", wikiPageZan.getCommentId());
|
// wrapper.eq(wikiPageZan.getCommentId() != null, "comment_id", wikiPageZan.getCommentId());
|
||||||
List<WikiPageZan> zanList = wikiPageZanService.list(wrapper);
|
// List<WikiPageZan> zanList = wikiPageZanService.list(wrapper);
|
||||||
return DocResponseJson.ok(zanList);
|
// return DocResponseJson.ok(zanList);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public ResponseJson<Object> update(WikiPageZan wikiPageZan) {
|
public ResponseJson<Object> update(WikiPageZan wikiPageZan) {
|
||||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
wikiPageZanService.zanPage(wikiPageZan);
|
||||||
UpdateWrapper<WikiPageZan> wrapper = new UpdateWrapper<>();
|
|
||||||
wrapper.eq("create_uid", currentUser.getUserId());
|
|
||||||
wrapper.eq("page_id", wikiPageZan.getPageId());
|
|
||||||
wrapper.eq(wikiPageZan.getCommentId() != null, "comment_id", wikiPageZan.getCommentId());
|
|
||||||
WikiPageZan pageZan = wikiPageZanService.getOne(wrapper);
|
|
||||||
if (pageZan != null) {
|
|
||||||
return DocResponseJson.warn("您已经赞过了哦~");
|
|
||||||
}
|
|
||||||
wikiPageZan.setCreateTime(new Date());
|
|
||||||
wikiPageZan.setCreateUserId(currentUser.getUserId());
|
|
||||||
wikiPageZanService.save(wikiPageZan);
|
|
||||||
return DocResponseJson.ok();
|
return DocResponseJson.ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ public class WikiSpaceController {
|
|||||||
wrapper.in("type", 1, 2);
|
wrapper.in("type", 1, 2);
|
||||||
} else if(wikiSpace.getType() == 1 || wikiSpace.getType() == 2) {
|
} else if(wikiSpace.getType() == 1 || wikiSpace.getType() == 2) {
|
||||||
wrapper.eq(wikiSpace.getType() != null, "type", wikiSpace.getType());
|
wrapper.eq(wikiSpace.getType() != null, "type", wikiSpace.getType());
|
||||||
wrapper.eq(Objects.equals(wikiSpace.getType(), 2), "create_uid", wikiSpace.getCreateUserId());
|
wrapper.eq(Objects.equals(wikiSpace.getType(), 2), "create_user_id", wikiSpace.getCreateUserId());
|
||||||
} else if(wikiSpace.getType() == 3) {
|
} else if(wikiSpace.getType() == 3) {
|
||||||
wrapper.eq("create_uid", currentUser.getUserId());
|
wrapper.eq("create_user_id", currentUser.getUserId());
|
||||||
}
|
}
|
||||||
List<WikiSpace> authList = wikiSpaceService.list(wrapper);
|
List<WikiSpace> authList = wikiSpaceService.list(wrapper);
|
||||||
return DocResponseJson.ok(authList);
|
return DocResponseJson.ok(authList);
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ public class WikiPageContentVo {
|
|||||||
private WikiPage wikiPage;
|
private WikiPage wikiPage;
|
||||||
private WikiPageContent pageContent;
|
private WikiPageContent pageContent;
|
||||||
private List<WikiPageFile> fileList;
|
private List<WikiPageFile> fileList;
|
||||||
|
private Integer selfZan;
|
||||||
|
|
||||||
public WikiPage getWikiPage() {
|
public WikiPage getWikiPage() {
|
||||||
return wikiPage;
|
return wikiPage;
|
||||||
@@ -34,4 +35,12 @@ public class WikiPageContentVo {
|
|||||||
public void setFileList(List<WikiPageFile> fileList) {
|
public void setFileList(List<WikiPageFile> fileList) {
|
||||||
this.fileList = fileList;
|
this.fileList = fileList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getSelfZan() {
|
||||||
|
return selfZan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelfZan(Integer selfZan) {
|
||||||
|
this.selfZan = selfZan;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,12 +46,14 @@
|
|||||||
<!--:before-remove="beforeRemove"-->
|
<!--:before-remove="beforeRemove"-->
|
||||||
<!--:on-exceed="handleExceed"-->
|
<!--:on-exceed="handleExceed"-->
|
||||||
<el-upload
|
<el-upload
|
||||||
class="upload-demo"
|
class="upload-page-file"
|
||||||
action="zyplayer-doc-wiki/common/upload"
|
action="zyplayer-doc-wiki/common/upload"
|
||||||
|
:on-success="uploadFileSuccess"
|
||||||
name="files"
|
name="files"
|
||||||
show-file-list
|
show-file-list
|
||||||
multiple
|
multiple
|
||||||
:limit="3">
|
:data="uploadFormData"
|
||||||
|
:limit="999">
|
||||||
<el-button icon="el-icon-upload">上传附件</el-button>
|
<el-button icon="el-icon-upload">上传附件</el-button>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
</div>
|
</div>
|
||||||
@@ -69,6 +71,25 @@
|
|||||||
<div class="wiki-content">
|
<div class="wiki-content">
|
||||||
<div v-html="pageContent.content"></div>
|
<div v-html="pageContent.content"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div style="margin-top: 10px; font-size: 14px;">
|
||||||
|
<span style="vertical-align: top;" class="is-link">
|
||||||
|
<img src="webjars/doc-wiki/img/zan.png" style="vertical-align: middle;">
|
||||||
|
<span v-show="wikiPage.selfZan == 0" v-on:click="zanPage(1)">赞</span>
|
||||||
|
<span v-show="wikiPage.selfZan == 1" v-on:click="zanPage(0)">踩</span>
|
||||||
|
</span>
|
||||||
|
<span style="margin-left: 10px;vertical-align: top;">
|
||||||
|
<span v-if="wikiPage.selfZan == 0 && wikiPage.zanNum <= 0">成为第一个赞同者</span>
|
||||||
|
<span v-else-if="wikiPage.selfZan == 0 && wikiPage.zanNum > 0"><span class="is-link" v-on:click="showZanPageUser">{{wikiPage.zanNum}}人</span>赞了它</span>
|
||||||
|
<span v-else-if="wikiPage.selfZan == 1 && wikiPage.zanNum <= 1">我赞了它</span>
|
||||||
|
<span v-else-if="wikiPage.selfZan == 1 && wikiPage.zanNum > 1"><span class="is-link" v-on:click="showZanPageUser">我和{{wikiPage.zanNum-1}}个其他人</span>赞了它</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div style="margin-top: 10px;">
|
||||||
|
<el-input type="textarea" v-model="commentTextInput" :rows="2" placeholder="请输入评论内容"></el-input>
|
||||||
|
<div align="right" style="margin-top: 5px;">
|
||||||
|
<el-button v-on:click="submitPageComment">提交评论</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row type="border-card" v-show="rightContentType == 2">
|
<el-row type="border-card" v-show="rightContentType == 2">
|
||||||
<div style="margin-bottom: 10px;">
|
<div style="margin-bottom: 10px;">
|
||||||
@@ -141,6 +162,9 @@
|
|||||||
pageContent: {},
|
pageContent: {},
|
||||||
pageFileList: [],
|
pageFileList: [],
|
||||||
uploadFileList: [],
|
uploadFileList: [],
|
||||||
|
uploadFormData: {pageId: 0},
|
||||||
|
// 评论相关
|
||||||
|
commentTextInput: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@@ -151,7 +175,26 @@
|
|||||||
this.init();
|
this.init();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
editWiki(){
|
zanPage(yn) {
|
||||||
|
var param = {yn: yn, pageId: app.wikiPage.id};
|
||||||
|
ajaxTemp("zyplayer-doc-wiki/page/zan/update", "post", "json", param, function (json) {
|
||||||
|
if (validateResult(json)) {
|
||||||
|
app.wikiPage.selfZan = yn;
|
||||||
|
app.wikiPage.zanNum = app.wikiPage.zanNum + (yn == 1 ? 1 : -1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
showZanPageUser() {
|
||||||
|
|
||||||
|
},
|
||||||
|
submitPageComment() {
|
||||||
|
Toast.success(app.commentTextInput);
|
||||||
|
},
|
||||||
|
uploadFileSuccess(response) {
|
||||||
|
app.pageFileList.push(response.data);
|
||||||
|
Toast.success("上传成功!");
|
||||||
|
},
|
||||||
|
editWiki() {
|
||||||
this.rightContentType = 2;
|
this.rightContentType = 2;
|
||||||
this.newPageId = app.wikiPage.id;
|
this.newPageId = app.wikiPage.id;
|
||||||
this.newPageTitle = app.wikiPage.name;
|
this.newPageTitle = app.wikiPage.name;
|
||||||
@@ -183,7 +226,7 @@
|
|||||||
ajaxTemp("zyplayer-doc-wiki/page/update", "post", "json", param, function (json) {
|
ajaxTemp("zyplayer-doc-wiki/page/update", "post", "json", param, function (json) {
|
||||||
if (validateResult(json)) {
|
if (validateResult(json)) {
|
||||||
Toast.success("保存成功!");
|
Toast.success("保存成功!");
|
||||||
this.loadPageDetail(json.data.id);
|
app.loadPageDetail(json.data.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -201,9 +244,12 @@
|
|||||||
var param = {id: pageId};
|
var param = {id: pageId};
|
||||||
ajaxTemp("zyplayer-doc-wiki/page/detail", "post", "json", param, function (json) {
|
ajaxTemp("zyplayer-doc-wiki/page/detail", "post", "json", param, function (json) {
|
||||||
if (validateResult(json)) {
|
if (validateResult(json)) {
|
||||||
app.wikiPage = json.data.wikiPage || {};
|
var wikiPage = json.data.wikiPage || {};
|
||||||
|
wikiPage.selfZan = json.data.selfZan || 0;
|
||||||
|
app.wikiPage = wikiPage;
|
||||||
app.pageContent = json.data.pageContent || {};
|
app.pageContent = json.data.pageContent || {};
|
||||||
app.pageFileList = json.data.fileList || [];
|
app.pageFileList = json.data.fileList || [];
|
||||||
|
app.uploadFormData = {pageId: app.wikiPage.id};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -278,6 +324,9 @@
|
|||||||
.wiki-title{font-size: 20px;}
|
.wiki-title{font-size: 20px;}
|
||||||
.wiki-author{font-size: 14px;padding: 10px 0;}
|
.wiki-author{font-size: 14px;padding: 10px 0;}
|
||||||
.wiki-content{font-size: 14px;}
|
.wiki-content{font-size: 14px;}
|
||||||
|
|
||||||
|
.upload-page-file .el-upload-list{display: none;}
|
||||||
|
.is-link{color: #1e88e5;cursor: pointer;}
|
||||||
</style>
|
</style>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 433 B |
Reference in New Issue
Block a user