|
|
|
@ -1,13 +1,21 @@
|
|
|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.api.hrm.bean.FieldItem;
|
|
|
|
|
import com.api.hrm.util.FieldType;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.organization.entity.config.dto.EditTableColumns;
|
|
|
|
|
import com.engine.organization.entity.config.dto.EditTableDatas;
|
|
|
|
|
import com.engine.organization.entity.config.params.QTXConfigParam;
|
|
|
|
|
import com.engine.organization.entity.config.po.QTXConfigPO;
|
|
|
|
|
import com.engine.organization.enums.MobileTerminalEnum;
|
|
|
|
|
import com.engine.organization.mapper.config.ConfigMapper;
|
|
|
|
|
import com.engine.organization.service.ConfigService;
|
|
|
|
|
import com.engine.organization.util.OrganizationDateUtil;
|
|
|
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
|
import com.weaver.file.ConfigOperator;
|
|
|
|
|
import lombok.SneakyThrows;
|
|
|
|
|
import org.apache.commons.beanutils.BeanUtils;
|
|
|
|
|
import org.apache.commons.codec.binary.Base64;
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
|
|
|
|
@ -17,6 +25,8 @@ import javax.crypto.spec.SecretKeySpec;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Author liang.cheng
|
|
|
|
@ -26,6 +36,8 @@ import java.nio.charset.StandardCharsets;
|
|
|
|
|
*/
|
|
|
|
|
public class ConfigServiceImpl extends Service implements ConfigService {
|
|
|
|
|
|
|
|
|
|
private static final String VALUE_ONE = "1";
|
|
|
|
|
|
|
|
|
|
private static ConfigMapper getConfigMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(ConfigMapper.class);
|
|
|
|
|
}
|
|
|
|
@ -38,21 +50,72 @@ public class ConfigServiceImpl extends Service implements ConfigService {
|
|
|
|
|
String enable = bb.getPropValue("qtx_sso_login", "enable");
|
|
|
|
|
String userAgent = qtx.getUserAgent();
|
|
|
|
|
boolean termianal = MobileTerminalEnum.containsEnumValue(userAgent);
|
|
|
|
|
if (Boolean.parseBoolean(enable)) {
|
|
|
|
|
if (VALUE_ONE.equals(enable)) {
|
|
|
|
|
QTXConfigPO qtxConfig = getConfigMapper().selectConfigInfo();
|
|
|
|
|
String domain = "0".equals(qtx.getDomainIndex()) ? qtxConfig.getUrl() : qtxConfig.getSecondUrl();
|
|
|
|
|
String address = termianal ? qtxConfig.getMobileAddress() : qtxConfig.getPcAddress();
|
|
|
|
|
String accessKey = URLEncoder.encode(getAccessKey(qtxConfig.getAppSecret()),"utf-8");
|
|
|
|
|
hkUrl = StrUtil.format("{}/{}?accessKey={}&type={}&username={}&whole={}",domain,address,accessKey,qtx.getType(),qtx.getLoginId(),qtx.getWhole());
|
|
|
|
|
hkUrl = StrUtil.format("{}{}?accessKey={}&type={}&username={}&whole={}&domainIndex={}",domain,address,accessKey,qtx.getType(),qtx.getLoginId(),qtx.getWhole(),qtx.getDomainIndex());
|
|
|
|
|
}else {
|
|
|
|
|
String accessKey = URLEncoder.encode(getAccessKey(bb.getPropValue("qtx_sso_login", "app_secret")),"utf-8");
|
|
|
|
|
String domain = "0".equals(qtx.getDomainIndex()) ? bb.getPropValue("qtx_sso_login","url") : bb.getPropValue("qtx_sso_login","url1");
|
|
|
|
|
String address = termianal ? bb.getPropValue("qtx_sso_login","h5address") : bb.getPropValue("qtx_sso_login","pcaddress");
|
|
|
|
|
hkUrl = StrUtil.format("{}/{}?accessKey={}&type={}&username={}&whole={}",domain,address,accessKey,qtx.getType(),qtx.getLoginId(),qtx.getWhole());
|
|
|
|
|
hkUrl = StrUtil.format("{}{}?accessKey={}&type={}&username={}&whole={}&domainIndex={}",domain,address,accessKey,qtx.getType(),qtx.getLoginId(),qtx.getWhole(),qtx.getDomainIndex());
|
|
|
|
|
}
|
|
|
|
|
return hkUrl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SneakyThrows
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> selectConfigInfo() {
|
|
|
|
|
Map<String, Object> map = new HashMap<>(16);
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
List<EditTableColumns> columns = new ArrayList<>();
|
|
|
|
|
columns.add(EditTableColumns.builder().dataIndex("appSecret").key("appSecret").title("密钥").width("20%").build());
|
|
|
|
|
columns.add(EditTableColumns.builder().dataIndex("url").key("url").title("外网").width("20%").build());
|
|
|
|
|
columns.add(EditTableColumns.builder().dataIndex("secondUrl").key("secondUrl").title("内网").width("20%").build());
|
|
|
|
|
columns.add(EditTableColumns.builder().dataIndex("pcAddress").key("pcAddress").title("PC地址").width("20%").build());
|
|
|
|
|
columns.add(EditTableColumns.builder().dataIndex("mobileAddress").key("mobileAddress").title("H5地址").width("20%").build());
|
|
|
|
|
columns.forEach(editTableColumns -> editTableColumns.setCom(getFieldDetailInfo(editTableColumns)));
|
|
|
|
|
QTXConfigPO qtxConfigPO = getConfigMapper().selectConfigInfo();
|
|
|
|
|
EditTableDatas datas = new EditTableDatas();
|
|
|
|
|
if (Objects.nonNull(qtxConfigPO)) {
|
|
|
|
|
BeanUtils.copyProperties(datas, qtxConfigPO);
|
|
|
|
|
}
|
|
|
|
|
map.put("isopenconfig",bb.getPropValue("qtx_sso_login","enable"));
|
|
|
|
|
map.put("columns",columns);
|
|
|
|
|
map.put("datas", Collections.singletonList(datas));
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SneakyThrows
|
|
|
|
|
@Override
|
|
|
|
|
public int saveConfigInfo(QTXConfigPO qtxConfigPO, String isopenconfig) {
|
|
|
|
|
ConfigOperator ConfigOperator = new ConfigOperator();
|
|
|
|
|
ConfigOperator.setProp("qtx_sso_login.properties", "enable", isopenconfig);
|
|
|
|
|
qtxConfigPO.setCreator(user.getUID());
|
|
|
|
|
qtxConfigPO.setCreateDate(OrganizationDateUtil.getFormatLocalDate(LocalDate.now()));
|
|
|
|
|
getConfigMapper().deleteAll();
|
|
|
|
|
return getConfigMapper().insertIgnoreNull(qtxConfigPO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*表格控件
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private static List<FieldItem> getFieldDetailInfo(EditTableColumns columns) {
|
|
|
|
|
List<FieldItem> ls = new ArrayList<>();
|
|
|
|
|
FieldItem fieldItem = new FieldItem();
|
|
|
|
|
fieldItem.setKey(columns.getKey());
|
|
|
|
|
fieldItem.setLabel("");
|
|
|
|
|
fieldItem.setType(FieldType.INPUT);
|
|
|
|
|
fieldItem.setViewAttr(3);
|
|
|
|
|
fieldItem.setWidth(columns.getWidth());
|
|
|
|
|
ls.add(fieldItem);
|
|
|
|
|
return ls;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static String getAccessKey(String appSecret) {
|
|
|
|
|
String data = System.currentTimeMillis() + "||" + appSecret;
|
|
|
|
|
String IV = appSecret.substring(appSecret.length() - 16);
|
|
|
|
|