|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
public class ResourceModel {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取行政区划code
|
|
|
|
|
*
|
|
|
|
|
* @param area_id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String getAreaCode(String area_id) {
|
|
|
|
|
String sql = "select * from t_dm_area where id=?";
|
|
|
|
|
return Db.findFirst(sql, area_id).getStr("area_code");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取当前用户的行政区划
|
|
|
|
|
*
|
|
|
|
|
* @param identity_id
|
|
|
|
|
* @param person_id
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String getAreaCode(int identity_id, String person_id) {
|
|
|
|
|
String area_code = "";
|
|
|
|
|
//省管理员,直接返回云南省的code
|
|
|
|
|
if (identity_id == 1) area_code = "530000";
|
|
|
|
|
//如果是市州用户,直接返回市州用户的行政区划
|
|
|
|
|
String sql = "select * from t_sys_loginperson where person_id=?";
|
|
|
|
|
Record record = Db.findFirst(sql, person_id);
|
|
|
|
|
if (identity_id == 2) {
|
|
|
|
|
String city_id = record.getStr("city_id");
|
|
|
|
|
area_code = getAreaCode(city_id);
|
|
|
|
|
}
|
|
|
|
|
if (identity_id == 3) {
|
|
|
|
|
String area_id = record.getStr("area_id");
|
|
|
|
|
area_code = getAreaCode(area_id);
|
|
|
|
|
}
|
|
|
|
|
return area_code;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取知识库分页数据
|
|
|
|
|
*
|
|
|
|
|
* @param pageNum
|
|
|
|
|
* @param pageSize
|
|
|
|
|
*/
|
|
|
|
|
public Page<Record> getZskPage(int pageNum, int pageSize) {
|
|
|
|
|
SqlPara sqlPara = Db.getSqlPara("YltWxGzh.getZskPage");
|
|
|
|
|
Page<Record> page = Db.paginate(pageNum, pageSize, sqlPara);
|
|
|
|
|
return page;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:删除知识库文档
|
|
|
|
|
*
|
|
|
|
|
* @param id
|
|
|
|
|
*/
|
|
|
|
|
public void delZskDocument(int id) {
|
|
|
|
|
String sql = "delete from t_zsk_files where id=?";
|
|
|
|
|
Db.update(sql, id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:上传知识库文档
|
|
|
|
|
* @param name
|
|
|
|
|
* @param file_name
|
|
|
|
|
* @param type_id
|
|
|
|
|
* @param identity_id
|
|
|
|
|
* @param area_code
|
|
|
|
|
*/
|
|
|
|
|
public void uploadZskDocument(String name, String file_name, int type_id, int identity_id, String area_code) {
|
|
|
|
|
Record record = new Record();
|
|
|
|
|
record.set("name", name);
|
|
|
|
|
record.set("file_name", file_name);
|
|
|
|
|
record.set("type_id", type_id);
|
|
|
|
|
record.set("identity_id", identity_id);
|
|
|
|
|
record.set("area_code", area_code);
|
|
|
|
|
Db.save("t_zsk_files", "id", record);
|
|
|
|
|
}
|
|
|
|
|
}
|