Browse Source

文章详情获取

zxm
zhangxiaomeng 1 year ago
parent
commit
ce7b03a240
  1. 10
      kcui/src/api/kcInfo.js
  2. 46
      kcui/src/view/TWInfo.vue
  3. 89
      src/main/java/com/main/woka/Web/Controller/KcInfoController.java
  4. 9
      src/main/java/com/main/woka/Web/Dao/KcInfo.java

10
kcui/src/api/kcInfo.js

@ -12,3 +12,13 @@ export function getDocList(data) {
} }
}) })
} }
export function getTwInfo(id) {
return request({
url: '/kcDoc/getTwInfo',
method: 'get',
id,
headers: {
'Authorization': 'Bearer '+ getToken() // 将 token 放在请求头中
}
})
}

46
kcui/src/view/TWInfo.vue

@ -44,9 +44,17 @@
</div> </div>
<div <div
style="width: 94%;height:3vw;position: absolute;z-index: 1;top: 4.9vw;left: 3%;background-color: #0c3068;box-shadow: 0px -9px 10px 0px rgb(75,230,255);"></div> style="width: 94%;height:3vw;position: absolute;z-index: 1;top: 4.9vw;left: 3%;background-color: #0c3068;box-shadow: 0px -9px 10px 0px rgb(75,230,255);"></div>
<!-- <img src="../assets/img/rightHead.png"--> <div style="width: 94.4%;height: 2.9vw;position: absolute;z-index: 2;margin-left: 2.6%;top: 5vw;" v-if="this.userType==1">
<!-- style="width: 96%;height:5vw;position: absolute;z-index: 1;top: 3.1vw;left: 2%;">--> <div
<div style="width: 94.4%;height: 2.9vw;position: absolute;z-index: 2;margin-left: 2.6%;top: 5vw;"> style="width: 100%;height: 100%;display: flex;flex-direction: row;line-height: 2.9vw;text-align: center;color: #ffffff;">
<div style="width: 10%;">序号</div>
<div style="width: 20%;">标题</div>
<div style="width: 60%;">图片</div>
<div style="width: 10%;">详情</div>
<div style="width: 10%;">操作</div>
</div>
</div>
<div style="width: 94.4%;height: 2.9vw;position: absolute;z-index: 2;margin-left: 2.6%;top: 5vw;" v-if="this.userType==0">
<div <div
style="width: 100%;height: 100%;display: flex;flex-direction: row;line-height: 2.9vw;text-align: center;color: #ffffff;"> style="width: 100%;height: 100%;display: flex;flex-direction: row;line-height: 2.9vw;text-align: center;color: #ffffff;">
<div style="width: 10%;">序号</div> <div style="width: 10%;">序号</div>
@ -58,12 +66,24 @@
</div> </div>
<div class="rightList"> <div class="rightList">
<img src="../assets/img/rightList.png" style="width: 100%;height: 95%;position: absolute;z-index: 1;"/> <img src="../assets/img/rightList.png" style="width: 100%;height: 95%;position: absolute;z-index: 1;"/>
<div class="rightListContent"> <div class="rightListContent" v-if="this.userType==0">
<div class="oneRight" v-for="item in contentList" :key="item">
<div style="width: 8%;">{{ item.id }}</div>
<div style="width: 22%;">{{ item.name }}</div>
<div style="width: 60%;">图片</div>
<div style="width: 10%;text-decoration: underline;font-style: italic;">点击查看详情</div>
</div>
</div>
<div class="rightListContent" v-if="this.userType==1">
<div class="oneRight" v-for="item in contentList" :key="item"> <div class="oneRight" v-for="item in contentList" :key="item">
<div style="width: 8%;">{{ item.id }}</div> <div style="width: 8%;">{{ item.id }}</div>
<div style="width: 22%;">{{ item.name }}</div> <div style="width: 22%;">{{ item.name }}</div>
<div style="width: 60%;">图片</div> <div style="width: 60%;">图片</div>
<div style="width: 10%;text-decoration: underline;font-style: italic;">点击查看详情</div> <div style="width: 10%;text-decoration: underline;font-style: italic;">点击查看详情</div>
<div style="width: 9%;text-decoration: underline;font-style: italic;display: flex;justify-content: space-around;margin-left: 1%;">
<div @click="editTw(item.id)">修改</div>
<div @click="deleteTw(item.id)">删除</div>
</div>
</div> </div>
</div> </div>
<div class="pageList"> <div class="pageList">
@ -88,7 +108,7 @@
<script> <script>
import headInfo from '@/components/Head.vue'; import headInfo from '@/components/Head.vue';
import Foot from "@/components/Foot.vue"; import Foot from "@/components/Foot.vue";
import {getDocList} from "@/api/kcInfo"; import {getDocList, getTwInfo} from "@/api/kcInfo";
export default { export default {
// eslint-disable-next-line vue/multi-word-component-names // eslint-disable-next-line vue/multi-word-component-names
@ -167,6 +187,22 @@ export default {
console.log(this.onePagesList) console.log(this.onePagesList)
}) })
},
//
deleteTw(){
console.log("这是删除操作")
},
editTw(id){
//
var docId = id;
getTwInfo(docId).then((res)=>{
console.log(res);
})
console.log("这是修改操作")
} }
}, },
mounted() { mounted() {

89
src/main/java/com/main/woka/Web/Controller/KcInfoController.java

@ -4,10 +4,13 @@ import com.main.woka.Common.core.AjaxResult;
import com.main.woka.Web.Dao.KcInfo; import com.main.woka.Web.Dao.KcInfo;
import com.main.woka.Web.Mapper.KcFileMapper; import com.main.woka.Web.Mapper.KcFileMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import java.io.BufferedReader;
import org.springframework.web.bind.annotation.RestController; import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.List;
@RestController @RestController
@RequestMapping("/kcDoc") @RequestMapping("/kcDoc")
@ -21,25 +24,63 @@ public class KcInfoController extends BaseController {
public AjaxResult getDocList(@RequestBody KcInfo kcInfo) { public AjaxResult getDocList(@RequestBody KcInfo kcInfo) {
// int pageNum = kcInfo.getPageNum() == null ? 1 : kcInfo.getPageNum(); int pageNum = kcInfo.getPageNum() == null ? 1 : kcInfo.getPageNum();
// int pageSize = kcInfo.getPageSize() == null ? 10 : kcInfo.getPageSize(); int pageSize = kcInfo.getPageSize() == null ? 10 : kcInfo.getPageSize();
// int offset = (pageNum - 1) * pageSize; int offset = (pageNum - 1) * pageSize;
//
// kcInfo.setOffset(offset); kcInfo.setOffset(offset);
// Long total = kcFileMapper.getKcCount(kcInfo); Long total = kcFileMapper.getKcCount(kcInfo);
// List<KcInfo> list = kcFileMapper.getkcList(kcInfo); List<KcInfo> list = kcFileMapper.getkcList(kcInfo);
//
// int totalPages = (int) Math.ceil((double) total / pageSize); int totalPages = (int) Math.ceil((double) total / pageSize);
//
// AjaxResult ajax = new AjaxResult(); AjaxResult ajax = new AjaxResult();
// ajax.put("list",list); ajax.put("list",list);
// ajax.put("total",total); ajax.put("total",total);
// ajax.put("totalPages",totalPages); ajax.put("totalPages",totalPages);
// ajax.put("pageSize",pageSize); ajax.put("pageSize",pageSize);
//
//
//
// return AjaxResult.success(ajax); return AjaxResult.success(ajax);
return null; // return null;
}
//管理员修改文件
@GetMapping("/getTwInfo")
public AjaxResult editTwInfo(@RequestParam("id") Long id){
System.out.println(id);
AjaxResult ajax = new AjaxResult();
KcInfo aa = kcFileMapper.selectById(id);
String path = aa.getTwUrl();
File file = new File(path);
String string = txt2String(file);
aa.setContentInfo(string);
ajax.put("data",aa);
return AjaxResult.success(ajax);
}
//读取txt文件方法
public static String txt2String(File file) {
StringBuilder result = new StringBuilder();
try {
// 构造一个BufferedReader类来读取文件
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
// BufferedReader br = new BufferedReader(new FileReader(file));
String s = null;
// 使用readLine方法,一次读一行
while ((s = br.readLine()) != null) {
result.append(System.lineSeparator() + s);
}
br.close();
} catch (Exception e) {
e.printStackTrace();
}
return result.toString();
} }
} }

9
src/main/java/com/main/woka/Web/Dao/KcInfo.java

@ -37,6 +37,15 @@ public class KcInfo {
private Integer offset; private Integer offset;
private String contentInfo;//文章内容
public String getContentInfo() {
return contentInfo;
}
public void setContentInfo(String contentInfo) {
this.contentInfo = contentInfo;
}
public Long getId() { public Long getId() {
return id; return id;

Loading…
Cancel
Save