Merge pull request 'feature/cl' (#208) from feature/cl into develop
Reviewed-on: http://221.226.25.34:3000/liang.cheng/weaver-hrm-organization/pulls/208
This commit is contained in:
commit
a0f703099e
|
|
@ -0,0 +1,33 @@
|
|||
package com.engine.organization.entity.config.dto;
|
||||
|
||||
import com.api.hrm.bean.FieldItem;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/8/22 10:48 AM
|
||||
* @Description:
|
||||
* @Version 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class EditTableColumns {
|
||||
|
||||
private List<FieldItem> com;
|
||||
|
||||
private String dataIndex;
|
||||
|
||||
private String key;
|
||||
|
||||
private String title;
|
||||
|
||||
private String width;
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.engine.organization.entity.config.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2023/8/22 1:44 PM
|
||||
* @Description:
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class EditTableDatas {
|
||||
|
||||
private String appSecret;
|
||||
|
||||
private String url;
|
||||
|
||||
private String pcAddress;
|
||||
|
||||
private String mobileAddress;
|
||||
|
||||
private String secondUrl;
|
||||
}
|
||||
|
|
@ -12,14 +12,11 @@ import lombok.*;
|
|||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
public class QTXConfigParam {
|
||||
|
||||
public QTXConfigParam() {
|
||||
this.type = "1";
|
||||
this.domainIndex = "0";
|
||||
this.whole = "0";
|
||||
}
|
||||
|
||||
|
||||
private String loginId;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.engine.organization.mapper.config;
|
|||
|
||||
|
||||
import com.engine.organization.entity.config.po.QTXConfigPO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
/**
|
||||
* 企通学配置Mapper
|
||||
|
|
@ -18,4 +20,22 @@ public interface ConfigMapper {
|
|||
*/
|
||||
QTXConfigPO selectConfigInfo();
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 保存配置信息
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/8/22 3:28 PM
|
||||
* @param: [editTableDatas]
|
||||
* @return: int
|
||||
*/
|
||||
int insertIgnoreNull(QTXConfigPO qtxConfigPO);
|
||||
|
||||
/**
|
||||
* @Description: 删除
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/8/22 3:37 PM
|
||||
* @param: []
|
||||
* @return: void
|
||||
*/
|
||||
void deleteAll();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
<result column="mobile_address" property="mobileAddress"/>
|
||||
<result column="second_url" property="secondUrl"/>
|
||||
<result column="creator" property="creator"/>
|
||||
<result column="create_date" property="createDate"/>
|
||||
<result column="createdate" property="createDate"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
, t.mobile_address
|
||||
, t.second_url
|
||||
, t.creator
|
||||
, t.create_date
|
||||
, t.createdate
|
||||
</sql>
|
||||
|
||||
|
||||
|
|
@ -33,4 +33,113 @@
|
|||
from JCL_ORG_QTXCONFIG t
|
||||
</select>
|
||||
|
||||
<insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.config.po.QTXConfigPO" keyProperty="id"
|
||||
keyColumn="id" useGeneratedKeys="true">
|
||||
INSERT INTO JCL_ORG_QTXCONFIG
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="appSecret != null">
|
||||
app_secret,
|
||||
</if>
|
||||
<if test="url != null">
|
||||
url,
|
||||
</if>
|
||||
<if test="pcAddress != null">
|
||||
pc_address,
|
||||
</if>
|
||||
<if test="mobileAddress != null">
|
||||
mobile_address,
|
||||
</if>
|
||||
<if test="secondUrl != null ">
|
||||
second_url,
|
||||
</if>
|
||||
<if test="creator != null ">
|
||||
creator,
|
||||
</if>
|
||||
<if test="createDate != null ">
|
||||
createdate,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||
<if test="appSecret != null">
|
||||
#{appSecret},
|
||||
</if>
|
||||
<if test="url != null">
|
||||
#{url},
|
||||
</if>
|
||||
<if test="pcAddress != null">
|
||||
#{pcAddress},
|
||||
</if>
|
||||
<if test="mobileAddress != null">
|
||||
#{mobileAddress},
|
||||
</if>
|
||||
<if test="secondUrl != null ">
|
||||
#{secondUrl},
|
||||
</if>
|
||||
<if test="creator != null ">
|
||||
#{creator},
|
||||
</if>
|
||||
<if test="createDate != null ">
|
||||
#{createDate},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<insert id="insertIgnoreNull" parameterType="com.engine.organization.entity.config.po.QTXConfigPO" databaseId="oracle">
|
||||
<selectKey keyProperty="id" resultType="long" order="AFTER">
|
||||
select JCL_ORG_QTXCONFIG_ID.currval from dual
|
||||
</selectKey>
|
||||
INSERT INTO JCL_ORG_QTXCONFIG
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="appSecret != null">
|
||||
app_secret,
|
||||
</if>
|
||||
<if test="url != null">
|
||||
url,
|
||||
</if>
|
||||
<if test="pcAddress != null">
|
||||
pc_address,
|
||||
</if>
|
||||
<if test="mobileAddress != null">
|
||||
mobile_address,
|
||||
</if>
|
||||
<if test="secondUrl != null ">
|
||||
second_url,
|
||||
</if>
|
||||
<if test="creator != null ">
|
||||
creator,
|
||||
</if>
|
||||
<if test="createDate != null ">
|
||||
createdate,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="VALUES (" suffix=")" suffixOverrides=",">
|
||||
<if test="appSecret != null">
|
||||
#{appSecret},
|
||||
</if>
|
||||
<if test="url != null">
|
||||
#{url},
|
||||
</if>
|
||||
<if test="pcAddress != null">
|
||||
#{pcAddress},
|
||||
</if>
|
||||
<if test="mobileAddress != null">
|
||||
#{mobileAddress},
|
||||
</if>
|
||||
<if test="secondUrl != null ">
|
||||
#{secondUrl},
|
||||
</if>
|
||||
<if test="creator != null ">
|
||||
#{creator},
|
||||
</if>
|
||||
<if test="createDate != null ">
|
||||
#{createDate},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
<delete id="deleteAll">
|
||||
delete from JCL_ORG_QTXCONFIG
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
package com.engine.organization.service;
|
||||
|
||||
import com.engine.organization.entity.config.params.QTXConfigParam;
|
||||
import com.engine.organization.entity.config.po.QTXConfigPO;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
|
|
@ -20,4 +22,23 @@ public interface ConfigService {
|
|||
* @return: java.lang.String
|
||||
*/
|
||||
String ssoLogin(QTXConfigParam qtxConfigParam) throws UnsupportedEncodingException;
|
||||
|
||||
|
||||
/**
|
||||
* @Description: h获取配置信息
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/8/22 10:35 AM
|
||||
* @param: []
|
||||
* @return: java.util.Map<java.lang.String,java.lang.Object>
|
||||
*/
|
||||
Map<String,Object> selectConfigInfo();
|
||||
|
||||
/**
|
||||
* @Description: 保存配置信息
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2023/8/22 3:17 PM
|
||||
* @param: [qtxConfigPO, isopenconfig]
|
||||
* @return: void
|
||||
*/
|
||||
int saveConfigInfo(QTXConfigPO qtxConfigPO, String isopenconfig);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -1,18 +1,21 @@
|
|||
package com.engine.organization.web;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
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.service.ConfigService;
|
||||
import com.engine.organization.service.impl.ConfigServiceImpl;
|
||||
import com.engine.organization.util.response.ReturnResult;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
|
|
@ -36,9 +39,42 @@ public class ConfigController {
|
|||
public void ssoLogin(@Context HttpServletRequest request, @Context HttpServletResponse response,
|
||||
@QueryParam("type") String type,@QueryParam("domainIndex") String domainIndex,@QueryParam("whole") String whole) throws IOException {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
QTXConfigParam qtxConfigParam = QTXConfigParam.builder().loginId(user.getLoginid()).type(type).domainIndex(domainIndex).whole(whole)
|
||||
QTXConfigParam qtxConfigParam = QTXConfigParam.builder().loginId(user.getLoginid())
|
||||
.type(type == null ? "1" : type)
|
||||
.domainIndex(domainIndex == null ? "0" : domainIndex)
|
||||
.whole(whole == null ? "0" : whole)
|
||||
.userAgent(request.getHeader("user-agent")).build();
|
||||
String url = getConfigService(user).ssoLogin(qtxConfigParam);
|
||||
response.sendRedirect(url);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/selectConfigInfo")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult selectConfigInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
return ReturnResult.successed(getConfigService(user).selectConfigInfo());
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@Path("/saveConfigInfo")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ReturnResult saveConfigInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
String editTable = request.getParameter("editTable");
|
||||
String isopenconfig = request.getParameter("isopenconfig");
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
QTXConfigPO qtxConfigPO = objectMapper.readValue(editTable, QTXConfigPO.class);
|
||||
return ReturnResult.successed(getConfigService(user).saveConfigInfo(qtxConfigPO,isopenconfig));
|
||||
} catch (Exception e) {
|
||||
return ReturnResult.exceptionHandle(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue