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.

113 lines
3.8 KiB

3 years ago
package com.dsideal.FengHuang.Zjb.Model;
import com.dsideal.FengHuang.LoginPerson.Model.LoginPersonModel;
import com.dsideal.FengHuang.Util.CommonUtil;
import com.dsideal.FengHuang.Util.IpUtil;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.SqlPara;
3 years ago
import java.util.ArrayList;
import java.util.HashMap;
3 years ago
import java.util.List;
3 years ago
import java.util.Map;
3 years ago
public class ZjbModel {
/*
*/
public void delModulePage(int module_id, int page) {
String sql = "delete from t_zjb_module_page where module_id=? and page=?";
Db.update(sql, module_id, page);
}
/*
2022-12-26
*/
public void saveModulePage(int module_id, int page, String json) {
delModulePage(module_id, page);
Record record = new Record();
record.set("module_id", module_id);
record.set("page", page);
record.set("json", json);
Db.save("t_zjb_module_page", "module_id,page", record);
}
3 years ago
/*
JSON
*/
public String getModulePage(int module_id, int page) {
String sql = "select json from t_zjb_module_page where module_id=? and page=?";
List<Record> list = Db.find(sql, module_id, page);
if (list.size() > 0) return list.get(0).getStr("json");
return "[]";
}
3 years ago
public Record getMoudleInfo(int module_id) {
String sql = "select * from t_zjb_module where module_id=?";
return Db.findFirst(sql, module_id);
}
public List<Record> getModulePageFillInfo(int module_id) {
String sql = "select * from t_zjb_module_page where module_id=?";
List<Record> exist = Db.find(sql, module_id);
Map<Integer, String> _map = new HashMap<>();
for (Record record : exist) {
_map.put(record.getInt("page"), record.getStr("json"));
}
Record record = getMoudleInfo(module_id);
int page_count = record.getInt("page_count");
List<Record> res = new ArrayList<>();
for (int i = 1; i <= page_count; i++) {
Record r = new Record();
r.set("page", i);
if (_map.containsKey(i)) {
r.set("json", _map.get(i));
r.set("filled", true);
} else {
r.set("json", "[]");
r.set("filled", false);
}
res.add(r);
}
return res;
}
3 years ago
public Record getTaskInfo(int task_id) {
return Db.findById("t_zjb_task", "task_id", task_id);
}
public List<Record> getTaskPageFillInfo(int task_id) {
Record rTask = getTaskInfo(task_id);
int module_id = rTask.getInt("module_id");
Record record = getMoudleInfo(module_id);
int page_count = record.getInt("page_count");
String sql = "select * from t_zjb_task_fill where task_id=?";
List<Record> exist = Db.find(sql, task_id);
Map<Integer, String> _map = new HashMap<>();
for (Record r1 : exist) {
_map.put(r1.getInt("page"), r1.getStr("json"));
}
List<Record> res = new ArrayList<>();
for (int i = 1; i <= page_count; i++) {
Record r = new Record();
r.set("page", i);
if (_map.containsKey(i)) {
r.set("json", _map.get(i));
r.set("filled", true);
} else {
r.set("json", "[]");
r.set("filled", false);
}
res.add(r);
}
return res;
}
3 years ago
}