|
|
@ -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(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|