Browse Source

文章上传以及修改

zxm
zhangxiaomeng 1 year ago
parent
commit
65176b8345
  1. BIN
      kcui/src/assets/img/typeHeadChoose.png
  2. 215
      kcui/src/view/TWInfoXq.vue
  3. 77
      src/main/java/com/main/woka/Web/Controller/FileUpdateController.java
  4. 41
      src/main/java/com/main/woka/Web/Dao/KcTwImg.java
  5. 13
      src/main/java/com/main/woka/Web/Mapper/TwImgMapper.java
  6. 44
      src/main/resources/CoreNLP-chinese.properties
  7. 34
      src/main/resources/Mapper/TwImgMapper.xml

BIN
kcui/src/assets/img/typeHeadChoose.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

215
kcui/src/view/TWInfoXq.vue

@ -0,0 +1,215 @@
<template>
<div style="width: 100%;height: 100%;">
<img style="width: 100%;height: 100%;position: absolute;z-index:-1;" src="../assets/img/twbg1.jpg">
<headInfo style="position: absolute;z-index: 100"></headInfo>
<div class="content">
<div class="leftContent">
<div class="leftBox1">
<div style="width: 50%;margin: 0 auto;">
<p style="font-size: 1vw;">Hi,{{ userName }}~</p>
<p style="font-size: 0.7vw;">欢迎使用课程辅助系统</p>
</div>
</div>
<div class="leftBox2">
<div class="muluBox">
<img src="../assets/img/leftBox.png" style="width: 100%;object-fit: contain;z-index: 1;position: absolute;">
<div class="muluList">
<div v-for="item in mulu" :key="item">
<div class="oneMulu" v-if="page!=item" @click="goInfo(item.info)">
<div style="width: 80%;text-align: center;">{{ item.name }}</div>
<img src="../assets/img/jiantou.png"
style="width: 0.9vw;height:0.9vw;object-fit: contain;float: right;margin-top: 13%;">
</div>
<div class="oneMuluXuan" v-else>
<div style="width: 72%;text-align: center;">{{ item.name }}</div>
<img src="../assets/img/jiantou.png"
style="width: 0.9vw;height:0.9vw;object-fit: contain;float: right;margin-top: 8%;">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="rightContent">
<div class="contentInfo">
<div class="contentTitle">{{contentInfo.title}}</div>
<div class="contentText" v-html="contentInfo.content"></div>
</div>
</div>
</div>
<div style="width: 100%;height: 3%;position: fixed;bottom: 0px;z-index: 100">
<foot></foot>
</div>
</div>
</template>
<script>
import headInfo from "@/components/Head.vue";
import Foot from "@/components/Foot.vue";
import {getTwInfo} from "@/api/kcInfo";
export default {
// eslint-disable-next-line vue/multi-word-component-names
name: 'TWInfoXq',
components: {Foot, headInfo},
data() {
return{
docId:undefined,
level:0,
url:"",
userName:"",
mulu: [
{id: 0, name: "图文资源", info: "TwInfo"},
{id: 1, name: "视频资源", info: "SpInfo"},
{id: 2, name: "动画显示", info: "DhInfo"},
{id: 3, name: "计算模块", info: "JsInfo"},
{id: 4, name: "知识图谱", info: "Graph"},
{id: 4, name: "帮助文档", info: "Help"}
],
contentInfo:{
title:"",
content:""
},
}
},
methods:{
goInfo(info) {
console.log(info)
this.$router.push('/' + info)
},
getInfo(){
var data = {
id:this.docId
}
getTwInfo(data).then((res)=>{
this.contentInfo.title = res.data.data.name
this.contentInfo.content = res.data.data.contentInfo
})
}
},
mounted() {
this.docId = this.$route.query.id;
this.userType = localStorage.getItem("type");
this.userName = localStorage.getItem("name");
this.getInfo();
}
}
</script>
<style scoped>
.content {
width: 100%;
height: 86%;
}
.leftContent {
width: 14%;
height: 100%;
float: left;
margin-top: 4.4%;
}
.leftBox1 {
width: 100%;
height: 10%;
margin-top: 12%;
color: #7cdeff;
}
.leftBox2 {
width: 100%;
height: 90%;
}
.muluBox {
margin: 3% 14%;
height: 92%;
width: 72%;
position: relative;
}
.muluList {
width: 100%;
height: 90%;
//background-color: #7cdeff;
display: flex;
flex-direction: column;
position: absolute;
z-index: 2;
margin-top: 20%;
}
.oneMulu {
width: 80%;
height: 2.5vw;
line-height: 2.5vw;
font-size: 0.9vw;
border-bottom: 1px solid #0d3455;
margin-left: 10%;
color: #d1d3d7;
display: flex;
flex-direction: row;
}
.oneMuluXuan {
background-image: url("../assets/img/xuan.png");
width: 90%;
height: 2.5vw;
line-height: 2.5vw;
font-size: 0.9vw;
color: #d1d3d7;
display: flex;
flex-direction: row;
padding-left: 10%;
}
.rightContent {
width: 84%;
height: 100%;
float: left;
position: relative;
}
.contentInfo{
width: 100%;
height: 96%;
background-color: rgba(20, 119, 208, 0.82);
position: absolute;
z-index: 101;
margin-top: 7%;
border-radius: 1vw;
}
.contentTitle{
width: 100%;
height: 8%;
font-size: 1.5vw;
color: #ffffff;
text-align: center;
letter-spacing: 5px;
line-height: 3vw;
}
.contentText{
width: 96%;
height: 89%;
margin-top: 1%;
font-size: 1vw;
margin-left: 2%;
overflow-y: scroll;
color: #ffffff;
}
</style>

77
src/main/java/com/main/woka/Web/Controller/FileUpdateController.java

@ -0,0 +1,77 @@
package com.main.woka.Web.Controller;
import com.main.woka.Common.core.AjaxResult;
import com.main.woka.Common.util.file.FileUploadUtils;
import com.main.woka.Common.util.file.FileUtils;
import com.main.woka.Config.RuoYiConfig;
import com.main.woka.Config.ServerConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
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 java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
import java.util.Date;
@RestController
@RequestMapping("/fileUpdate")
public class FileUpdateController extends BaseController {
// 定义上传文件的存储路径
private static final String UPLOAD_DIR = "D:/kcfz/upload/";
@PostMapping("/upload")
public AjaxResult uploadFile(@RequestParam("file") MultipartFile file) {
if (file.isEmpty()) {
return AjaxResult.error();
}
try {
// 确保上传目录存在
File uploadDir = new File(UPLOAD_DIR);
if (!uploadDir.exists()) {
uploadDir.mkdirs();
}
// 获取文件名并生成唯一的文件名
String fileName = generateUniqueFileName(file.getOriginalFilename());
Path filePath = Paths.get(UPLOAD_DIR, fileName);
// 将文件写入磁盘
Files.copy(file.getInputStream(), filePath);
// 返回文件访问路径
String fileAccessPath = "http://127.0.0.1:10031/profile/" + fileName;
AjaxResult ajaxResult = new AjaxResult();
ajaxResult.put("fileName",fileName);
ajaxResult.put("url",fileAccessPath);
return AjaxResult.success(ajaxResult);
} catch (IOException e) {
e.printStackTrace();
return AjaxResult.error();
}
}
// 生成唯一的文件名
private String generateUniqueFileName(String originalFileName) {
String extension = "";
int i = originalFileName.lastIndexOf('.');
if (i > 0) {
extension = originalFileName.substring(i);
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String timestamp = sdf.format(new Date());
return timestamp + "_" + Math.abs(originalFileName.hashCode()) + extension;
}
}

41
src/main/java/com/main/woka/Web/Dao/KcTwImg.java

@ -0,0 +1,41 @@
package com.main.woka.Web.Dao;
public class KcTwImg {
private Long imgId;
private Long twId;
private String imgUrl;
public Long getImgId() {
return imgId;
}
public void setImgId(Long imgId) {
this.imgId = imgId;
}
public Long getTwId() {
return twId;
}
public void setTwId(Long twId) {
this.twId = twId;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
}
@Override
public String toString() {
return "KcTwImg{" +
"imgId=" + imgId +
", twId=" + twId +
", imgUrl='" + imgUrl + '\'' +
'}';
}
}

13
src/main/java/com/main/woka/Web/Mapper/TwImgMapper.java

@ -0,0 +1,13 @@
package com.main.woka.Web.Mapper;
import com.main.woka.Web.Dao.KcTwImg;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface TwImgMapper {
public int insertTwImg(List<KcTwImg> list);
List<KcTwImg> getKcTwImgList(Long id);
}

44
src/main/resources/CoreNLP-chinese.properties

@ -0,0 +1,44 @@
# Pipeline options - lemma is no-op for Chinese but currently needed because coref demands it (bad old requirements system)
#设定了管道中包括哪些Annotators(一个Annotator就是你需要的文本分析分析工具, 他的结果就是一个或多个Annotation)
#segment:分词, ssplit:分隔, pos: 词性标注, lemma: has->have, ner:命名实体识别, parse:语法分析
annotators = segment, ssplit, pos, lemma, ner, parse, sentiment, mention, coref
#annotators = segment, ssplit, pos, parse, sentiment
# segment 分词
customAnnotatorClass.segment = edu.stanford.nlp.pipeline.ChineseSegmenterAnnotator
segment.model = D:/tupudata/nlp/stanford-corenlp-3.9.1-models-chinese/edu/stanford/nlp/models/segmenter/chinese/pku.gz
segment.sighanCorporaDict = D:/tupudata/nlp/stanford-corenlp-3.9.1-models-chinese/edu/stanford/nlp/models/segmenter/chinese
segment.serDictionary = D:/tupudata/nlp/stanford-corenlp-3.9.1-models-chinese/edu/stanford/nlp/models/segmenter/chinese/dict-chris6.ser.gz
segment.sighanPostProcessing = true
# sentence split
ssplit.boundaryTokenRegex = [.]|[!?]+|[\u3002]|[\uFF01\uFF1F]+
# pos
pos.model = D:/tupudata/nlp/stanford-corenlp-3.9.1-models-chinese/edu/stanford/nlp/models/pos-tagger/chinese-distsim/chinese-distsim.tagger
#ner 此处设定了ner使用的语言、模型(crf),目前SUTime只支持英文,不支持中文,所以设置为false。
ner.language = chinese
ner.model = D:/tupudata/nlp/stanford-corenlp-3.9.1-models-chinese/edu/stanford/nlp/models/ner/chinese.misc.distsim.crf.ser.gz
ner.applyNumericClassifiers = true
ner.useSUTime = false
#parse
parse.model = D:/tupudata/nlp/stanford-corenlp-3.9.1-models-chinese/edu/stanford/nlp/models/lexparser/chineseFactored.ser.gz
# coref
coref.sieves = ChineseHeadMatch, ExactStringMatch, PreciseConstructs, StrictHeadMatch1, StrictHeadMatch2, StrictHeadMatch3, StrictHeadMatch4, PronounMatch
coref.input.type = raw
coref.postprocessing = true
coref.calculateFeatureImportance = false
coref.useConstituencyTree = true
coref.useSemantics = false
coref.md.type = RULE
coref.mode = hybrid
coref.path.word2vec =
coref.language = zh
coref.print.md.log = false
coref.defaultPronounAgreement = true
coref.zh.dict = D:/tupudata/nlp/stanford-corenlp-3.9.1-models-chinese/edu/stanford/nlp/models/dcoref/zh-attributes.txt.gz

34
src/main/resources/Mapper/TwImgMapper.xml

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.main.woka.Web.Mapper.TwImgMapper">
<resultMap id="KcTlFileResult" type="com.main.woka.Web.Dao.KcTwImg">
<result property="twId" column="tw_id"/>
<result property="imgId" column="img_id"/>
<result property="imgUrl" column="img_url"/>
</resultMap>
<!-- 新增图片 -->
<insert id="insertTwImg" parameterType="java.util.List">
INSERT INTO tw_img
(tw_id,img_url)
VALUES
<foreach collection="list" separator="," item="item">
(#{item.twId},#{item.imgUrl})
</foreach>
</insert>
<select id="getKcTwImgList" parameterType="java.lang.Long" resultMap="KcTlFileResult">
select * from tw_img
where tw_id = #{twId}
</select>
</mapper>
Loading…
Cancel
Save