You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
3.2 KiB
Java
93 lines
3.2 KiB
Java
1 year ago
|
package com.engine.salary.elog.util;
|
||
|
|
||
|
import com.alibaba.fastjson.JSONArray;
|
||
|
import com.alibaba.fastjson.JSONObject;
|
||
|
import com.engine.salary.elog.entity.dto.ElogBean;
|
||
|
import com.engine.salary.elog.entity.dto.FilterConditionDto;
|
||
|
import com.engine.salary.elog.entity.dto.ShowColumsDto;
|
||
|
import com.engine.salary.elog.enums.ElogConsts;
|
||
|
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
|
||
|
/**
|
||
|
* @Date: 2022/5/18 19:19
|
||
|
* @Author: deli.xu
|
||
|
* @Description: elog服务工具类
|
||
|
**/
|
||
|
public class ElogServiceUtils {
|
||
|
|
||
|
public static String getTableName(String module, String function) {
|
||
|
return getTableName(module, function, false);
|
||
|
}
|
||
|
|
||
|
public static String getTableName(String module, String function, boolean isDetail) {
|
||
|
String tablename = module + ElogConsts.TABLE_SPACER + function + ElogConsts.TABLE_SUFFIX + (isDetail ? ElogConsts.DETAIL_TABLE_SUFFIX : "");
|
||
|
sqlCheck(tablename);
|
||
|
return tablename;
|
||
|
}
|
||
|
|
||
|
public static void sqlCheck(String value) {
|
||
|
if (value != null) {
|
||
|
if (!value.matches("^[A-Za-z][a-zA-Z0-9_\\.,]{0,31}$")) {
|
||
|
throw new RuntimeException("sqlCheck failed ! value :" + value);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static ElogBean getElogBean(String data) {
|
||
|
JSONObject datas = JSONObject.parseObject(data);
|
||
|
ElogBean elogBean = new ElogBean();
|
||
|
String module = datas.getString("module");
|
||
|
String function = datas.getString("function");
|
||
|
String pageNum = datas.getString("current");
|
||
|
String pageSize = datas.getString("pageSize");
|
||
|
String searchMap = datas.getString("searchMap");
|
||
|
String transMethod = datas.getString("transMethod");
|
||
|
String authParams = datas.getString("authParams");
|
||
|
String showColums = datas.getString("showColums");
|
||
|
String filterConditions = datas.getString("filterConditions");
|
||
|
String downloadSize = datas.getString("downloadSize");
|
||
|
List<ShowColumsDto> showColumsDtos = JSONArray.parseArray(showColums, ShowColumsDto.class);
|
||
|
List<FilterConditionDto> filterConditionDtos = JSONArray.parseArray(filterConditions, FilterConditionDto.class);
|
||
|
Map authParamsJson = JSONObject.parseObject(authParams);
|
||
|
elogBean.setModule(module);
|
||
|
elogBean.setFunction(function);
|
||
|
elogBean.setCurrent(pageNum);
|
||
|
elogBean.setPageSize(pageSize);
|
||
|
elogBean.setSearchMap(searchMap);
|
||
|
elogBean.setTransMethod(transMethod);
|
||
|
elogBean.setDownloadSize(downloadSize);
|
||
|
elogBean.setShowColumns(showColumsDtos);
|
||
|
elogBean.setFilterConditionDtos(filterConditionDtos);
|
||
|
elogBean.setAuthParamsJson(authParamsJson);
|
||
|
return elogBean;
|
||
|
}
|
||
|
|
||
|
public static int getIntValue(String v) {
|
||
|
return getIntValue(v, -1);
|
||
|
}
|
||
|
|
||
|
public static int getIntValue(String v, int def) {
|
||
|
try {
|
||
|
return Integer.parseInt(v);
|
||
|
} catch (Exception var3) {
|
||
|
return def;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static long getLongValue(String v) {
|
||
|
return getLongValue(v, -1l);
|
||
|
}
|
||
|
|
||
|
public static long getLongValue(String v, long def) {
|
||
|
try {
|
||
|
return Long.parseLong(v);
|
||
|
} catch (Exception var3) {
|
||
|
return def;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|