机构管理中增加数据源管理
This commit is contained in:
parent
e1f6e1a1e6
commit
beb9729d9c
|
@ -237,4 +237,26 @@ public class SysDataSourceController extends JeecgController<SysDataSource, ISys
|
||||||
return this.sysDataSourceService.queryDepartList(addFLag);
|
return this.sysDataSourceService.queryDepartList(addFLag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过sysOrgCode查询
|
||||||
|
*
|
||||||
|
* @param sysOrgCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "多数据源管理-通过sysOrgCode查询")
|
||||||
|
@ApiOperation(value = "多数据源管理-通过id查询", notes = "多数据源管理-通过sysOrgCode查询")
|
||||||
|
@GetMapping(value = "/queryBySysOrgCode")
|
||||||
|
public Result<?> queryBySysOrgCode(@RequestParam(name = "sysOrgCode") String sysOrgCode) throws InterruptedException {
|
||||||
|
SysDataSource sysDataSource = sysDataSourceService.getBySysOrgCode(sysOrgCode);
|
||||||
|
//密码解密
|
||||||
|
if(sysDataSource!=null){
|
||||||
|
String dbPassword = sysDataSource.getDbPassword();
|
||||||
|
if(StringUtils.isNotBlank(dbPassword)){
|
||||||
|
String decodedStr = SecurityUtil.jiemi(dbPassword);
|
||||||
|
sysDataSource.setDbPassword(decodedStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.ok(sysDataSource);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,22 @@ public class SysDepart implements Serializable {
|
||||||
/**机构编码*/
|
/**机构编码*/
|
||||||
@Excel(name="机构编码",width=15)
|
@Excel(name="机构编码",width=15)
|
||||||
private String orgCode;
|
private String orgCode;
|
||||||
|
/**运营开始时间*/
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||||
|
private Date operationStartTime;
|
||||||
|
/**运营到期时间*/
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||||
|
private Date operationEndTime;
|
||||||
|
/**合同开始时间*/
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||||
|
private Date contractStartTime;
|
||||||
|
/**合同到期时间*/
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||||
|
private Date contractEndTime;
|
||||||
/**手机号*/
|
/**手机号*/
|
||||||
@Excel(name="手机号",width=15)
|
@Excel(name="手机号",width=15)
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
|
@ -170,7 +170,24 @@
|
||||||
|
|
||||||
<!--系统后台导出,根据父级id和租户id查询部门数据-->
|
<!--系统后台导出,根据父级id和租户id查询部门数据-->
|
||||||
<select id="getSysDepartList" resultType="org.jeecg.modules.system.vo.SysDepartExportVo">
|
<select id="getSysDepartList" resultType="org.jeecg.modules.system.vo.SysDepartExportVo">
|
||||||
SELECT id,depart_name,parent_id,depart_name_en,depart_order,description,org_category,org_code,mobile,fax,address,memo FROM sys_depart
|
SELECT
|
||||||
|
id,
|
||||||
|
depart_name,
|
||||||
|
parent_id,
|
||||||
|
depart_name_en,
|
||||||
|
depart_order,
|
||||||
|
description,
|
||||||
|
org_category,
|
||||||
|
org_code,
|
||||||
|
operation_start_time,
|
||||||
|
operation_end_time,
|
||||||
|
contract_start_time,
|
||||||
|
contract_end_time,
|
||||||
|
mobile,
|
||||||
|
fax,
|
||||||
|
address,
|
||||||
|
memo
|
||||||
|
FROM sys_depart
|
||||||
WHERE
|
WHERE
|
||||||
1=1
|
1=1
|
||||||
<if test="null != tenantId and 0 != tenantId">
|
<if test="null != tenantId and 0 != tenantId">
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package org.jeecg.modules.system.model;
|
package org.jeecg.modules.system.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import org.jeecg.modules.system.entity.SysDepart;
|
import org.jeecg.modules.system.entity.SysDepart;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -53,6 +55,14 @@ public class SysDepartTreeModel implements Serializable{
|
||||||
|
|
||||||
private String orgCode;
|
private String orgCode;
|
||||||
|
|
||||||
|
private Date operationStartTime;
|
||||||
|
|
||||||
|
private Date operationEndTime;
|
||||||
|
|
||||||
|
private Date contractStartTime;
|
||||||
|
|
||||||
|
private Date contractEndTime;
|
||||||
|
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
||||||
private String fax;
|
private String fax;
|
||||||
|
@ -101,6 +111,10 @@ public class SysDepartTreeModel implements Serializable{
|
||||||
this.orgCategory = sysDepart.getOrgCategory();
|
this.orgCategory = sysDepart.getOrgCategory();
|
||||||
this.orgType = sysDepart.getOrgType();
|
this.orgType = sysDepart.getOrgType();
|
||||||
this.orgCode = sysDepart.getOrgCode();
|
this.orgCode = sysDepart.getOrgCode();
|
||||||
|
this.operationStartTime = sysDepart.getOperationStartTime();
|
||||||
|
this.operationEndTime = sysDepart.getOperationEndTime();
|
||||||
|
this.contractStartTime = sysDepart.getContractStartTime();
|
||||||
|
this.contractEndTime = sysDepart.getContractEndTime();
|
||||||
this.mobile = sysDepart.getMobile();
|
this.mobile = sysDepart.getMobile();
|
||||||
this.fax = sysDepart.getFax();
|
this.fax = sysDepart.getFax();
|
||||||
this.address = sysDepart.getAddress();
|
this.address = sysDepart.getAddress();
|
||||||
|
@ -221,6 +235,38 @@ public class SysDepartTreeModel implements Serializable{
|
||||||
this.orgCode = orgCode;
|
this.orgCode = orgCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Date getOperationStartTime() {
|
||||||
|
return operationStartTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperationStartTime(Date operationStartTime) {
|
||||||
|
this.operationStartTime = operationStartTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getOperationEndTime() {
|
||||||
|
return operationEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOperationEndTime(Date operationEndTime) {
|
||||||
|
this.operationEndTime = operationEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getContractStartTime() {
|
||||||
|
return contractStartTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContractStartTime(Date contractStartTime) {
|
||||||
|
this.contractStartTime = contractStartTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getContractEndTime() {
|
||||||
|
return contractEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContractEndTime(Date contractEndTime) {
|
||||||
|
this.contractEndTime = contractEndTime;
|
||||||
|
}
|
||||||
|
|
||||||
public String getMobile() {
|
public String getMobile() {
|
||||||
return mobile;
|
return mobile;
|
||||||
}
|
}
|
||||||
|
@ -373,6 +419,10 @@ public class SysDepartTreeModel implements Serializable{
|
||||||
Objects.equals(orgCategory, model.orgCategory) &&
|
Objects.equals(orgCategory, model.orgCategory) &&
|
||||||
Objects.equals(orgType, model.orgType) &&
|
Objects.equals(orgType, model.orgType) &&
|
||||||
Objects.equals(orgCode, model.orgCode) &&
|
Objects.equals(orgCode, model.orgCode) &&
|
||||||
|
Objects.equals(operationStartTime, model.operationStartTime) &&
|
||||||
|
Objects.equals(operationEndTime, model.operationEndTime) &&
|
||||||
|
Objects.equals(contractStartTime, model.contractStartTime) &&
|
||||||
|
Objects.equals(contractEndTime, model.contractEndTime) &&
|
||||||
Objects.equals(mobile, model.mobile) &&
|
Objects.equals(mobile, model.mobile) &&
|
||||||
Objects.equals(fax, model.fax) &&
|
Objects.equals(fax, model.fax) &&
|
||||||
Objects.equals(address, model.address) &&
|
Objects.equals(address, model.address) &&
|
||||||
|
@ -395,9 +445,10 @@ public class SysDepartTreeModel implements Serializable{
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
|
||||||
return Objects.hash(id, parentId, departName, departNameEn, departNameAbbr,
|
return Objects.hash(id, parentId, departName, departNameEn, departNameAbbr,
|
||||||
departOrder, description, orgCategory, orgType, orgCode, mobile, fax, address,
|
departOrder, description, orgCategory, orgType, orgCode,
|
||||||
memo, status, delFlag, qywxIdentifier, createBy, createTime, updateBy, updateTime,
|
operationStartTime, operationEndTime, contractStartTime, contractEndTime,
|
||||||
children,directorUserIds);
|
mobile, fax, address, memo, status, delFlag, qywxIdentifier,
|
||||||
|
createBy, createTime, updateBy, updateTime, children,directorUserIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,4 +42,11 @@ public interface ISysDataSourceService extends IService<SysDataSource> {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Result<List<SysDataSource>> queryDepartList(String addFLag);
|
Result<List<SysDataSource>> queryDepartList(String addFLag);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过sysOrgCode查询
|
||||||
|
* @param sysOrgCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
SysDataSource getBySysOrgCode(String sysOrgCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@ import com.baomidou.dynamic.datasource.creator.DataSourceProperty;
|
||||||
import com.baomidou.dynamic.datasource.creator.druid.DruidDataSourceCreator;
|
import com.baomidou.dynamic.datasource.creator.druid.DruidDataSourceCreator;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import me.zhyd.oauth.log.Log;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.util.dynamic.db.DataSourceCachePool;
|
import org.jeecg.common.util.dynamic.db.DataSourceCachePool;
|
||||||
|
@ -17,6 +19,7 @@ import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 多数据源管理
|
* @Description: 多数据源管理
|
||||||
|
@ -25,6 +28,7 @@ import java.util.List;
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class SysDataSourceServiceImpl extends ServiceImpl<SysDataSourceMapper, SysDataSource> implements ISysDataSourceService {
|
public class SysDataSourceServiceImpl extends ServiceImpl<SysDataSourceMapper, SysDataSource> implements ISysDataSourceService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -48,7 +52,7 @@ public class SysDataSourceServiceImpl extends ServiceImpl<SysDataSourceMapper, S
|
||||||
boolean result = save(sysDataSource);
|
boolean result = save(sysDataSource);
|
||||||
if (result) {
|
if (result) {
|
||||||
//动态创建数据源
|
//动态创建数据源
|
||||||
//addDynamicDataSource(sysDataSource, dbPassword);
|
addDynamicDataSource(sysDataSource, dbPassword);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -68,10 +72,10 @@ public class SysDataSourceServiceImpl extends ServiceImpl<SysDataSourceMapper, S
|
||||||
}
|
}
|
||||||
Boolean result=updateById(sysDataSource);
|
Boolean result=updateById(sysDataSource);
|
||||||
if(result){
|
if(result){
|
||||||
//先删除老的数据源
|
// 先删除老的数据源
|
||||||
// removeDynamicDataSource(d.getCode());
|
removeDynamicDataSource(d.getCode());
|
||||||
//添加新的数据源
|
// 添加新的数据源
|
||||||
//addDynamicDataSource(sysDataSource,dbPassword);
|
addDynamicDataSource(sysDataSource,dbPassword);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -103,6 +107,14 @@ public class SysDataSourceServiceImpl extends ServiceImpl<SysDataSourceMapper, S
|
||||||
DataSource dataSource = dataSourceCreator.createDataSource(dataSourceProperty);
|
DataSource dataSource = dataSourceCreator.createDataSource(dataSourceProperty);
|
||||||
try {
|
try {
|
||||||
ds.addDataSource(sysDataSource.getCode(), dataSource);
|
ds.addDataSource(sysDataSource.getCode(), dataSource);
|
||||||
|
// Map<String, DataSource> map = ds.getDataSources();
|
||||||
|
// map.forEach((key, value) -> System.out.println(key + ": " + value));
|
||||||
|
// for (Map.Entry<String, DataSource> entry : map.entrySet()) {
|
||||||
|
// Log.error("=======================================>");
|
||||||
|
// Log.error(entry.getKey());
|
||||||
|
// DataSource dynamicDataSource = entry.getValue();
|
||||||
|
// Log.error("<=======================================");
|
||||||
|
// }
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -139,4 +151,16 @@ public class SysDataSourceServiceImpl extends ServiceImpl<SysDataSourceMapper, S
|
||||||
List<SysDataSource> list = baseMapper.queryDepartList(addFLag);
|
List<SysDataSource> list = baseMapper.queryDepartList(addFLag);
|
||||||
return Result.OK(list);
|
return Result.OK(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 机构列表查询
|
||||||
|
* @param sysOrgCode
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SysDataSource getBySysOrgCode(String sysOrgCode){
|
||||||
|
QueryWrapper<SysDataSource> qw = new QueryWrapper();
|
||||||
|
qw.lambda().eq(true, SysDataSource::getSysOrgCode, sysOrgCode);
|
||||||
|
return getOne(qw);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue