kgdxpr 1 year ago
commit 1ce716d988

@ -42,8 +42,9 @@ public class CollectModel {
* @return
*/
public int IS_THIRD_PARTY() {
GlobalModel model = new GlobalModel();
return Integer.parseInt(model.getGlobalValueByKey("third_party_base_data"));
//GlobalModel model = new GlobalModel();
//return Integer.parseInt(model.getGlobalValueByKey("third_party_base_data"));
return 0;
}
/**

@ -31,17 +31,17 @@ public class GlobalController extends Controller {
@LengthInterface({"province_name,2,10", "city_name,2,20"})
public void saveInstallArea(String province_name, String city_name) {
List<Record> records;
if (province_name == null || province_name.trim().length() == 0) {
if (province_name == null || province_name.trim().isEmpty()) {
records = model.getAreaIdByAreaName(province_name, city_name);
} else {
records = model.getAreaIdByAreaName(city_name);
}
if (records == null || records.size() == 0) {
if (records == null || records.isEmpty()) {
renderJson(CommonUtil.returnMessageJson(false, "没有找到对应的省和市!"));
return;
}
String area_id = records.get(0).getStr("id");
String area_id = records.getFirst().getStr("id");
//保存
GlobalModel model = new GlobalModel();
model.saveInstallArea(area_id);

@ -1,14 +1,26 @@
package com.dsideal.QingLong.Global.Model;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.SqlPara;
import java.util.ArrayList;
import java.util.List;
public class GlobalModel {
/**
*
*
* @return
*/
public String getInstallArea() {
String sql = "select COALESCE(global_value,'') as global_value from t_base_global where global_code = 'install_area'";
return Db.findFirst(sql).getStr("global_value");
}
/**
* KEYVALUE
*
@ -16,17 +28,13 @@ public class GlobalModel {
* @return
*/
public String getGlobalValueByKey(String key) {
String result = "";
try {
String sql = Db.getSql("global.getGlobalValueByKey");
List<Record> list = Db.find(sql, key);
if (list.size() > 0) {
result = list.get(0).getStr("global_value");
}
} catch (Exception e) {
e.printStackTrace();
String install_area = getInstallArea();
if (key.equals("install_area")) {//如果是获取安装地区
return install_area;
}
return result;
//获取当前安装地区,然后组装出查询条件
String sql = "select global_value from t_base_global where install_area=? and global_code=?";
return Db.findFirst(sql, install_area, key).getStr("global_value");
}
/**
@ -49,7 +57,10 @@ public class GlobalModel {
* @return
*/
public Page<Record> getGlobalList(int page, int limit) {
Page<Record> dataPage = Db.paginate(page, limit, Db.getSqlPara("global.getGlobalList"));
String install_area = getInstallArea();
Kv kv = Kv.by("install_area", install_area);
SqlPara sqlPara = Db.getSqlPara("global.getGlobalList", kv);
Page<Record> dataPage = Db.paginate(page, limit, sqlPara);
return dataPage;
}
@ -62,8 +73,9 @@ public class GlobalModel {
* @return
*/
public int checkGlobalCodeCount(String global_id, String globalCode) {
String sql = Db.getSql("global.checkGlobalCodeCount");
Record record = Db.find(sql, Integer.parseInt(global_id), globalCode).get(0);
String install_area = getInstallArea();
String sql = "select count(1) as c from t_base_global where global_id<>? and global_code=? and install_area=?";
Record record = Db.find(sql, Integer.parseInt(global_id), globalCode, install_area).getFirst();
return record.getInt("c");
}
@ -84,7 +96,7 @@ public class GlobalModel {
*/
public void updateGlobalById(String global_id, String global_type_id, String global_code, String global_value, String global_name, int sort_id) {
String sql = Db.getSql("global.updateGlobalById");
Db.update(sql,Integer.parseInt(global_type_id), global_code, global_value, global_name, sort_id, Integer.parseInt(global_id));
Db.update(sql, Integer.parseInt(global_type_id), global_code, global_value, global_name, sort_id, Integer.parseInt(global_id));
}
/**
@ -120,11 +132,16 @@ public class GlobalModel {
* @return
*/
public List<Record> getGlobalByCodes(String global_codesString) {
if (global_codesString.equals("install_area")) {
String sql = "select * from t_base_global where global_id=1";
return Db.find(sql);
}
String install_area = getInstallArea();
List<Record> returnRecords = new ArrayList<>();
String sql = Db.getSql("global.getGlobalByCodes");
String[] global_codes = global_codesString.split(",");
for (int i = 0; i < global_codes.length; i++) {
List<Record> ilist = Db.find(sql, global_codes[i]);
List<Record> ilist = Db.find(sql, global_codes[i], install_area);
for (int j = 0; j < ilist.size(); j++) {
returnRecords.add(ilist.get(j));
}
@ -161,6 +178,73 @@ public class GlobalModel {
public void saveInstallArea(String area_id) {
String sql = Db.getSql("global.saveInstallArea");
Db.update(sql, area_id);
}
//检查是不是存在以下的字段
//1、system_name 2、copy_right 3、sso_system_name 4、sso_copy_right
sql = "select * from t_base_global where install_area=? and global_code=?";
Record record = Db.findFirst(sql, area_id, "system_name");
if (record == null) {
sql = "select max(global_id)+1 as global_id from t_base_global";
int global_id = Db.findFirst(sql).getInt("global_id");
Record r = new Record();
r.set("global_id", global_id);
r.set("global_type_id", 1);
r.set("global_code", "system_name");
r.set("global_value", "系统名称");
r.set("global_name", "系统名称");
r.set("sort_id", 1);
r.set("install_area", area_id);
Db.save("t_base_global", "global_id", r);
}
// 2、copy_right
sql = "select * from t_base_global where install_area=? and global_code=?";
record = Db.findFirst(sql, area_id, "copy_right");
if (record == null) {
sql = "select max(global_id)+1 as global_id from t_base_global";
int global_id = Db.findFirst(sql).getInt("global_id");
Record r = new Record();
r.set("global_id", global_id);
r.set("global_type_id", 1);
r.set("global_code", "copy_right");
r.set("global_value", "版权信息");
r.set("global_name", "版权信息");
r.set("sort_id", 1);
r.set("install_area", area_id);
Db.save("t_base_global", "global_id", r);
}
//3、sso_system_name
sql = "select * from t_base_global where install_area=? and global_code=?";
record = Db.findFirst(sql, area_id, "sso_system_name");
if (record == null) {
sql = "select max(global_id)+1 as global_id from t_base_global";
int global_id = Db.findFirst(sql).getInt("global_id");
Record r = new Record();
r.set("global_id", global_id);
r.set("global_type_id", 1);
r.set("global_code", "sso_system_name");
r.set("global_value", "统一认证系统名称");
r.set("global_name", "统一认证系统名称");
r.set("sort_id", 1);
r.set("install_area", area_id);
Db.save("t_base_global", "global_id", r);
}
// 4、sso_copy_right
sql = "select * from t_base_global where install_area=? and global_code=?";
record = Db.findFirst(sql, area_id, "sso_copy_right");
if (record == null) {
sql = "select max(global_id)+1 as global_id from t_base_global";
int global_id = Db.findFirst(sql).getInt("global_id");
Record r = new Record();
r.set("global_id", global_id);
r.set("global_type_id", 1);
r.set("global_code", "sso_copy_right");
r.set("global_value", "统一认证版权信息");
r.set("global_name", "统一认证版权信息");
r.set("sort_id", 1);
r.set("install_area", area_id);
Db.save("t_base_global", "global_id", r);
}
}
}

@ -8,12 +8,7 @@
-- 获取所有分类
#sql("getGlobalList")
select global_id,global_type_id,global_code,global_value,global_name,sort_id from t_base_global order by sort_id
#end
-- 检查一个globalCode是不是重复
#sql("checkGlobalCodeCount")
select count(1) as c from t_base_global where global_id<>? and global_code=?
select global_id,global_type_id,global_code,global_value,global_name,sort_id from t_base_global where global_id=1 or install_area=#para(install_area) order by sort_id
#end
-- 增加一个全局变量设置
@ -38,7 +33,7 @@
-- 传入一组global_code 返回对应的数据
#sql("getGlobalByCodes")
select global_id,global_type_id,global_code,global_value,global_name from t_base_global where global_code=?
select global_id,global_type_id,global_code,global_value,global_name from t_base_global where global_code=? and install_area=?
#end
-- 获取area_id通过area_name

Loading…
Cancel
Save