You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
package com.dsideal.base.Res.Model;
|
|
|
|
|
|
|
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Page;
|
|
|
|
|
import com.jfinal.plugin.activerecord.SqlPara;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
|
|
|
|
|
public class ResourceModel {
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取知识库分页数据
|
|
|
|
|
*
|
|
|
|
|
* @param pageNum
|
|
|
|
|
* @param pageSize
|
|
|
|
|
*/
|
|
|
|
|
public Page<Record> getZskPage(int pageNum, int pageSize) throws UnsupportedEncodingException {
|
|
|
|
|
SqlPara sqlPara = Db.getSqlPara("YltWxGzh.getZskPage");
|
|
|
|
|
Page<Record> page = Db.paginate(pageNum, pageSize, sqlPara);
|
|
|
|
|
for (Record record : page.getList()) {
|
|
|
|
|
String url = record.getStr("url");
|
|
|
|
|
//进行base64处理,然后进行url_encode处理
|
|
|
|
|
// 对URL进行Base64编码
|
|
|
|
|
String base64Encoded = Base64.getEncoder().encodeToString(url.getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
// 对Base64编码后的字符串进行URL编码
|
|
|
|
|
String urlEncoded = URLEncoder.encode(base64Encoded, StandardCharsets.UTF_8.toString());
|
|
|
|
|
record.set("url", urlEncoded);
|
|
|
|
|
}
|
|
|
|
|
return page;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:上传文档
|
|
|
|
|
*
|
|
|
|
|
* @param name
|
|
|
|
|
* @param url
|
|
|
|
|
*/
|
|
|
|
|
public void uploadZskDocument(String name, String url) {
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
record.set("name", name);
|
|
|
|
|
record.set("url", url);
|
|
|
|
|
Db.use("ds_db").save("t_zsk_files", record);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:删除知识库文档
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
*/
|
|
|
|
|
public void delZskDocument(int id) {
|
|
|
|
|
String sql = "delete from ds_db.t_zsk_files where id=?";
|
|
|
|
|
Db.update(sql, id);
|
|
|
|
|
}
|
|
|
|
|
}
|