Compare commits

..

No commits in common. 'main' and 'dev' have entirely different histories.
main ... dev

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="migrated" value="true" />
<option name="pristineConfig" value="false" />
<option name="userId" value="-656edef7:190bac43930:-7ff9" />
</MTProjectMetadataState>
</option>
</component>
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="corretto-1.8" project-jdk-type="JavaSDK" />
</project>

@ -20,6 +20,7 @@
<spring-framework.version>5.3.33</spring-framework.version> <spring-framework.version>5.3.33</spring-framework.version>
<spring-security.version>5.7.12</spring-security.version> <spring-security.version>5.7.12</spring-security.version>
<druid.version>1.2.23</druid.version> <druid.version>1.2.23</druid.version>
<mp.version>3.4.1</mp.version>
<bitwalker.version>1.21</bitwalker.version> <bitwalker.version>1.21</bitwalker.version>
<swagger.version>3.0.0</swagger.version> <swagger.version>3.0.0</swagger.version>
<kaptcha.version>2.3.3</kaptcha.version> <kaptcha.version>2.3.3</kaptcha.version>
@ -30,6 +31,8 @@
<poi.version>4.1.2</poi.version> <poi.version>4.1.2</poi.version>
<velocity.version>2.3</velocity.version> <velocity.version>2.3</velocity.version>
<jwt.version>0.9.1</jwt.version> <jwt.version>0.9.1</jwt.version>
<mapstruct.version>1.6.2</mapstruct.version>
<lombok.version>1.18.22</lombok.version>
</properties> </properties>
<!-- 依赖声明 --> <!-- 依赖声明 -->
@ -70,6 +73,20 @@
<version>${druid.version}</version> <version>${druid.version}</version>
</dependency> </dependency>
<!-- Mybatis-Plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mp.version}</version>
</dependency>
<!-- MyBatis-Plus 分页插件 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
<version>${mp.version}</version>
</dependency>
<!-- 解析客户端操作系统、浏览器等 --> <!-- 解析客户端操作系统、浏览器等 -->
<dependency> <dependency>
<groupId>eu.bitwalker</groupId> <groupId>eu.bitwalker</groupId>
@ -77,13 +94,6 @@
<version>${bitwalker.version}</version> <version>${bitwalker.version}</version>
</dependency> </dependency>
<!-- pagehelper 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper.boot.version}</version>
</dependency>
<!-- 获取系统信息 --> <!-- 获取系统信息 -->
<dependency> <dependency>
<groupId>com.github.oshi</groupId> <groupId>com.github.oshi</groupId>
@ -181,6 +191,37 @@
<version>${sync.version}</version> <version>${sync.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.lyr</groupId>
<artifactId>sync-gather</artifactId>
<version>${sync.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>33.2.1-jre</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-core</artifactId>
<version>3.4.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>3.15.2</version>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
@ -191,6 +232,7 @@
<module>sync-quartz</module> <module>sync-quartz</module>
<module>sync-generator</module> <module>sync-generator</module>
<module>sync-common</module> <module>sync-common</module>
<module>sync-gather</module>
</modules> </modules>
<packaging>pom</packaging> <packaging>pom</packaging>
@ -200,11 +242,25 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version> <version>3.8.1</version>
<configuration> <configuration>
<source>${java.version}</source> <source>${java.version}</source>
<target>${java.version}</target> <target>${java.version}</target>
<encoding>${project.build.sourceEncoding}</encoding> <encoding>${project.build.sourceEncoding}</encoding>
<parameters>true</parameters>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

@ -43,6 +43,11 @@
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
<!-- 核心模块--> <!-- 核心模块-->
<dependency> <dependency>
<groupId>com.lyr</groupId> <groupId>com.lyr</groupId>
@ -61,6 +66,13 @@
<artifactId>sync-generator</artifactId> <artifactId>sync-generator</artifactId>
</dependency> </dependency>
<!-- 数据采集-->
<dependency>
<groupId>com.lyr</groupId>
<artifactId>sync-gather</artifactId>
</dependency>
</dependencies> </dependencies>

@ -14,15 +14,7 @@ public class RuoYiApplication {
public static void main(String[] args) { public static void main(String[] args) {
// System.setProperty("spring.devtools.restart.enabled", "false"); // System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(RuoYiApplication.class, args); SpringApplication.run(RuoYiApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" + System.out.println("(♥◠‿◠)ノ゙ 启动成功 ლ(´ڡ`ლ)゙");
" .-------. ____ __ \n" +
" | _ _ \\ \\ \\ / / \n" +
" | ( ' ) | \\ _. / ' \n" +
" |(_ o _) / _( )_ .' \n" +
" | (_,_).' __ ___(_ o _)' \n" +
" | |\\ \\ | || |(_,_)' \n" +
" | | \\ `' /| `-' / \n" +
" | | \\ / \\ / \n" +
" ''-' `'-' `-..-' ");
} }
} }

@ -33,7 +33,6 @@ public class SysLogininforController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')") @PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysLogininfor logininfor) { public TableDataInfo list(SysLogininfor logininfor) {
startPage();
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
return getDataTable(list); return getDataTable(list);
} }

@ -29,7 +29,7 @@ public class SysOperlogController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')") @PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysOperLog operLog) { public TableDataInfo list(SysOperLog operLog) {
startPage();
List<SysOperLog> list = operLogService.selectOperLogList(operLog); List<SysOperLog> list = operLogService.selectOperLogList(operLog);
return getDataTable(list); return getDataTable(list);
} }

@ -40,7 +40,7 @@ public class SysUserOnlineController extends BaseController {
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*"); Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>(); List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
for (String key : keys) { for (String key : keys) {
LoginUser user = redisCache.getCacheObject(key); LoginUser user = redisCache.getCacheObject(key, LoginUser.class);
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) { if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user)); userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
} else if (StringUtils.isNotEmpty(ipaddr)) { } else if (StringUtils.isNotEmpty(ipaddr)) {

@ -33,7 +33,7 @@ public class SysConfigController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:config:list')") @PreAuthorize("@ss.hasPermi('system:config:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysConfig config) { public TableDataInfo list(SysConfig config) {
startPage();
List<SysConfig> list = configService.selectConfigList(config); List<SysConfig> list = configService.selectConfigList(config);
return getDataTable(list); return getDataTable(list);
} }

@ -36,7 +36,7 @@ public class SysDictDataController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:list')") @PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysDictData dictData) { public TableDataInfo list(SysDictData dictData) {
startPage();
List<SysDictData> list = dictDataService.selectDictDataList(dictData); List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return getDataTable(list); return getDataTable(list);
} }

@ -30,7 +30,7 @@ public class SysDictTypeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:dict:list')") @PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysDictType dictType) { public TableDataInfo list(SysDictType dictType) {
startPage();
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
return getDataTable(list); return getDataTable(list);
} }

@ -31,7 +31,7 @@ public class SysNoticeController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:notice:list')") @PreAuthorize("@ss.hasPermi('system:notice:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysNotice notice) { public TableDataInfo list(SysNotice notice) {
startPage();
List<SysNotice> list = noticeService.selectNoticeList(notice); List<SysNotice> list = noticeService.selectNoticeList(notice);
return getDataTable(list); return getDataTable(list);
} }

@ -33,7 +33,7 @@ public class SysPostController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:post:list')") @PreAuthorize("@ss.hasPermi('system:post:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysPost post) { public TableDataInfo list(SysPost post) {
startPage();
List<SysPost> list = postService.selectPostList(post); List<SysPost> list = postService.selectPostList(post);
return getDataTable(list); return getDataTable(list);
} }

@ -51,7 +51,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:list')") @PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysRole role) { public TableDataInfo list(SysRole role) {
startPage();
List<SysRole> list = roleService.selectRoleList(role); List<SysRole> list = roleService.selectRoleList(role);
return getDataTable(list); return getDataTable(list);
} }
@ -171,7 +171,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:list')") @PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/allocatedList") @GetMapping("/authUser/allocatedList")
public TableDataInfo allocatedList(SysUser user) { public TableDataInfo allocatedList(SysUser user) {
startPage();
List<SysUser> list = userService.selectAllocatedList(user); List<SysUser> list = userService.selectAllocatedList(user);
return getDataTable(list); return getDataTable(list);
} }
@ -182,7 +182,7 @@ public class SysRoleController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:role:list')") @PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/unallocatedList") @GetMapping("/authUser/unallocatedList")
public TableDataInfo unallocatedList(SysUser user) { public TableDataInfo unallocatedList(SysUser user) {
startPage();
List<SysUser> list = userService.selectUnallocatedList(user); List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list); return getDataTable(list);
} }

@ -52,7 +52,7 @@ public class SysUserController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:user:list')") @PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysUser user) { public TableDataInfo list(SysUser user) {
startPage();
List<SysUser> list = userService.selectUserList(user); List<SysUser> list = userService.selectUserList(user);
return getDataTable(list); return getDataTable(list);
} }

@ -0,0 +1,15 @@
package com.lyr.web.controller.tool;
import org.springframework.web.bind.annotation.RestController;
/**
* @author liyc
* @date 2024/10/30
* @description TODO
**/
@RestController("/dataSourceManager")
public class DataSourceManagerController {
}

@ -5,13 +5,12 @@ spring:
port: 6379 port: 6379
database: 1 database: 1
password: eGDiN3RRhRNzrzjd password: eGDiN3RRhRNzrzjd
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid: druid:
# 主库数据源 # 主库数据源
master: master:
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${spring.redis.host}:3306/sync-data?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://${spring.redis.host}:3306/sync-data?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: K2bfP8rzG62ZSJGN password: K2bfP8rzG62ZSJGN
@ -19,6 +18,7 @@ spring:
slave: slave:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭
enabled: false enabled: false
driverClassName:
url: url:
username: username:
password: password:

@ -46,7 +46,7 @@ logging:
user: user:
password: password:
# 密码最大错误次数 # 密码最大错误次数
maxRetryCount: 5 maxRetryCount: 50
# 密码锁定时间默认10分钟 # 密码锁定时间默认10分钟
lockTime: 10 lockTime: 10
@ -100,25 +100,23 @@ token:
# 令牌有效期默认30分钟 # 令牌有效期默认30分钟
expireTime: 30 expireTime: 30
# MyBatis配置
mybatis: mybatis-plus:
# 搜索指定包别名
typeAliasesPackage: com.lyr.**.domain typeAliasesPackage: com.lyr.**.domain
# 配置mapper的扫描找到所有的mapper.xml映射文件
mapperLocations: classpath*:mapper/**/*Mapper.xml mapperLocations: classpath*:mapper/**/*Mapper.xml
# 加载全局的配置文件 mapperPackage: com.lyr.**.mapper
configLocation: classpath:mybatis/mybatis-config.xml configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# PageHelper分页插件 map-underscore-to-camel-case: true
pagehelper: global-config:
helperDialect: mysql db-config:
supportMethodsArguments: true id-type: AUTO
params: count=countSql banner: off
# Swagger配置 # Swagger配置
swagger: swagger:
# 是否开启swagger # 是否开启swagger
enabled: true enabled: false
# 请求前缀 # 请求前缀
pathMapping: /dev-api pathMapping: /dev-api

@ -35,11 +35,6 @@
<artifactId>spring-boot-starter-security</artifactId> <artifactId>spring-boot-starter-security</artifactId>
</dependency> </dependency>
<!-- pagehelper 分页插件 -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
</dependency>
<!-- 自定义验证注解 --> <!-- 自定义验证注解 -->
<dependency> <dependency>
@ -59,6 +54,12 @@
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<!-- 阿里JSON解析器 --> <!-- 阿里JSON解析器 -->
<dependency> <dependency>
<groupId>com.alibaba.fastjson2</groupId> <groupId>com.alibaba.fastjson2</groupId>
@ -95,10 +96,10 @@
<artifactId>jaxb-api</artifactId> <artifactId>jaxb-api</artifactId>
</dependency> </dependency>
<!-- redis 缓存操作 --> <!-- redisson 缓存操作 -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.redisson</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId> <artifactId>redisson-spring-boot-starter</artifactId>
</dependency> </dependency>
<!-- pool 对象池 --> <!-- pool 对象池 -->
@ -119,6 +120,27 @@
<artifactId>javax.servlet-api</artifactId> <artifactId>javax.servlet-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -16,8 +16,18 @@ import java.lang.annotation.*;
@Documented @Documented
@Inherited @Inherited
public @interface DataSource { public @interface DataSource {
/** /**
* *
*/ */
DataSourceType value() default DataSourceType.MASTER; DataSourceType value() default DataSourceType.MASTER;
/**
* (使,使value)
*
* @return
*/
String name() default "";
} }

@ -9,7 +9,7 @@ import org.springframework.stereotype.Component;
* @author ruoyi * @author ruoyi
*/ */
@Component @Component
@ConfigurationProperties(prefix = "ruoyi") @ConfigurationProperties(prefix = "sync")
public class RuoYiConfig { public class RuoYiConfig {
/** /**
* *

@ -1,18 +1,13 @@
package com.lyr.common.core.controller; package com.lyr.common.core.controller;
import com.github.pagehelper.PageHelper; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.pagehelper.PageInfo;
import com.lyr.common.constant.HttpStatus; import com.lyr.common.constant.HttpStatus;
import com.lyr.common.core.domain.AjaxResult; import com.lyr.common.core.domain.AjaxResult;
import com.lyr.common.core.domain.model.LoginUser; import com.lyr.common.core.domain.model.LoginUser;
import com.lyr.common.core.page.PageDomain;
import com.lyr.common.core.page.TableDataInfo; import com.lyr.common.core.page.TableDataInfo;
import com.lyr.common.core.page.TableSupport;
import com.lyr.common.utils.DateUtils; import com.lyr.common.utils.DateUtils;
import com.lyr.common.utils.PageUtils;
import com.lyr.common.utils.SecurityUtils; import com.lyr.common.utils.SecurityUtils;
import com.lyr.common.utils.StringUtils; import com.lyr.common.utils.StringUtils;
import com.lyr.common.utils.sql.SqlUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.WebDataBinder;
@ -44,31 +39,6 @@ public class BaseController {
}); });
} }
/**
*
*/
protected void startPage() {
PageUtils.startPage();
}
/**
*
*/
protected void startOrderBy() {
PageDomain pageDomain = TableSupport.buildPageRequest();
if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) {
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
PageHelper.orderBy(orderBy);
}
}
/**
* 线
*/
protected void clearPage() {
PageUtils.clearPage();
}
/** /**
* *
*/ */
@ -78,7 +48,17 @@ public class BaseController {
rspData.setCode(HttpStatus.SUCCESS); rspData.setCode(HttpStatus.SUCCESS);
rspData.setMsg("查询成功"); rspData.setMsg("查询成功");
rspData.setRows(list); rspData.setRows(list);
rspData.setTotal(new PageInfo(list).getTotal()); // rspData.setTotal(new Page(list).getTotal());
return rspData;
}
protected TableDataInfo getDataTable(IPage<?> page) {
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
rspData.setMsg("查询成功");
rspData.setRows(page.getRecords());
rspData.setTotal(page.getTotal());
return rspData; return rspData;
} }

@ -0,0 +1,31 @@
package com.lyr.common.core.domain;
import com.google.common.collect.ImmutableMap;
import com.lyr.common.constant.HttpStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.HashMap;
import java.util.Map;
/**
*
*
* @author liyc
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ServiceResult extends HashMap<String, Object> {
private Integer code;
private String message;
private Map data;
public static ServiceResult success(String name) {
ImmutableMap<Object, Object> data1 = ImmutableMap.of();
return new ServiceResult(HttpStatus.SUCCESS, name, data1);
}
}

@ -1,13 +1,16 @@
package com.lyr.common.core.page; package com.lyr.common.core.page;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lyr.common.utils.StringUtils; import com.lyr.common.utils.StringUtils;
import java.io.Serializable;
/** /**
* *
* *
* @author ruoyi * @author ruoyi
*/ */
public class PageDomain { public class PageDomain implements Serializable {
/** /**
* *
*/ */
@ -90,4 +93,11 @@ public class PageDomain {
public void setReasonable(Boolean reasonable) { public void setReasonable(Boolean reasonable) {
this.reasonable = reasonable; this.reasonable = reasonable;
} }
public Page toPage() {
return new Page(getPageNum(), this.getPageSize());
}
} }

@ -1,5 +1,6 @@
package com.lyr.common.core.redis; package com.lyr.common.core.redis;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundSetOperations; import org.springframework.data.redis.core.BoundSetOperations;
import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.HashOperations;
@ -97,6 +98,22 @@ public class RedisCache {
return operation.get(key); return operation.get(key);
} }
/**
* @param key
* @param clazz
* @param <T>
* @return
*/
public <T> T getCacheObject(final String key, Class clazz) {
Object cacheObject = this.getCacheObject(key);
if (cacheObject == null) {
return null;
}
Object object = JSONObject.parseObject(cacheObject.toString(), clazz);
return (T) object;
}
/** /**
* *
* *

@ -0,0 +1,45 @@
package com.lyr.common.core.redis;
import org.apache.commons.lang3.StringUtils;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;
import org.redisson.config.TransportMode;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* packageName com.ktg.mes.config
*
* @author liyc
* @date 2024/9/3
* @description TODO
**/
@Configuration
public class RedissonConfig {
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private String port;
@Value("${spring.redis.password}")
private String password;
@Bean
public RedissonClient redissonClient() {
Config config = new Config();
config.setTransportMode(TransportMode.NIO);
SingleServerConfig singleServerConfig = config.useSingleServer();
String address = String.format("redis://%s:%s", host, port);
singleServerConfig.setAddress(address);
if (StringUtils.isNotEmpty(password)) {
singleServerConfig.setPassword(password);
}
RedissonClient redisson = Redisson.create(config);
return redisson;
}
}

@ -14,5 +14,11 @@ public enum DataSourceType {
/** /**
* *
*/ */
SLAVE SLAVE,
/**
*
*/
EXTERNAL
} }

@ -0,0 +1,104 @@
package com.lyr.common.utils;
import com.lyr.common.exception.ServiceException;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.util.CollectionUtils;
import java.util.Collection;
import java.util.List;
/**
* @author Admin
*/
public class AssertUtil {
public static void notEmpty(Long val, String s, Integer... codes) throws ServiceException {
if (val == null) {
Integer code = (codes.length == 0) ? 500 : codes[0];
throw new ServiceException(s, code);
}
}
public static void notEmpty(Collection c, String s, Integer... codes) throws ServiceException {
if (CollectionUtils.isEmpty(c)) {
Integer code = (codes.length == 0) ? 500 : codes[0];
throw new ServiceException(s, code);
}
}
public static void notEmpty(String val, String s, Integer... codes) throws ServiceException {
if (StringUtils.isEmpty(val)) {
Integer code = (codes.length == 0) ? 500 : codes[0];
throw new ServiceException(s, code);
}
}
public static void notEmpty(Object val, String s, Integer... codes) throws ServiceException {
if (val == null) {
Integer code = (codes.length == 0) ? 500 : codes[0];
throw new ServiceException(s, code);
}
}
/**
*
*
* @param obj
* @param s
*/
public static void empty(Object obj, String s, Integer... codes) {
if (null != obj) {
Integer code = (codes.length == 0) ? 500 : codes[0];
throw new ServiceException(s, code);
}
}
public static void empty(Object obj, String s, List<T> t, Integer... codes) {
if (null != obj) {
Integer code = (codes.length == 0) ? 500 : codes[0];
throw new ServiceException(s, code);
}
}
public static void empty(Collection c, String s) {
if (!CollectionUtils.isEmpty(c)) {
throw new ServiceException(s, 500);
}
}
public static void notEqual(boolean val, String s, Integer... codes) {
if (val) {
Integer code = (codes.length == 0) ? 500 : codes[0];
throw new ServiceException(s, code);
}
}
public static void equal(boolean val, String s) {
notEqual(!val, s);
}
public static void isFalse(boolean b, String s, Integer... codes) {
if (b) {
Integer code = (codes.length == 0) ? 500 : codes[0];
throw new ServiceException(s, code);
}
}
public static void isTrue(boolean b, String s, Integer... codes) throws ServiceException {
if (!b) {
Integer code = (codes.length == 0) ? 500 : codes[0];
throw new ServiceException(s, code);
}
}
public static void test() {
throw new ServiceException("222");
}
}

@ -1,32 +0,0 @@
package com.lyr.common.utils;
import com.github.pagehelper.PageHelper;
import com.lyr.common.core.page.PageDomain;
import com.lyr.common.core.page.TableSupport;
import com.lyr.common.utils.sql.SqlUtil;
/**
*
*
* @author ruoyi
*/
public class PageUtils extends PageHelper {
/**
*
*/
public static void startPage() {
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
Boolean reasonable = pageDomain.getReasonable();
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
}
/**
* 线
*/
public static void clearPage() {
PageHelper.clearPage();
}
}

@ -0,0 +1,49 @@
package com.lyr.common.utils;
import org.springframework.context.annotation.Bean;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
/**
* spel
*
* @author liyc
* @date 2024/10/30
* @description TODO
**/
@Component
public class SpElUtil {
@Resource
public ExpressionParser expressionParser;
@Bean
public ExpressionParser expressionParser() {
return new SpelExpressionParser();
}
/**
*
*
* @param method
* @param args
* @param expression
* @return
*/
public String parseExpression(Method method, Object[] args, String expression) {
StandardEvaluationContext context = new StandardEvaluationContext();
Parameter[] parameters = method.getParameters();
for (int i = 0; i < parameters.length; i++) {
Parameter parameter = parameters[i];
context.setVariable(parameter.getName(), args[i]);
}
return expressionParser.parseExpression(expression).getValue(context, String.class);
}
}

@ -36,6 +36,15 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC
return (T) beanFactory.getBean(name); return (T) beanFactory.getBean(name);
} }
public static <T> T getBeanOfNull(String name) throws BeansException {
try {
return (T) beanFactory.getBean(name);
} catch (BeansException e) {
}
return null;
}
/** /**
* requiredType * requiredType
* *

@ -35,6 +35,17 @@
<artifactId>druid-spring-boot-starter</artifactId> <artifactId>druid-spring-boot-starter</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
</dependency>
<!-- 验证码 --> <!-- 验证码 -->
<dependency> <dependency>
<groupId>pro.fessional</groupId> <groupId>pro.fessional</groupId>
@ -59,6 +70,12 @@
<artifactId>sync-system</artifactId> <artifactId>sync-system</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -1,8 +1,11 @@
package com.lyr.framework.aspectj; package com.lyr.framework.aspectj;
import com.lyr.common.annotation.DataSource; import com.lyr.common.annotation.DataSource;
import com.lyr.common.exception.ServiceException;
import com.lyr.common.utils.SpElUtil;
import com.lyr.common.utils.StringUtils; import com.lyr.common.utils.StringUtils;
import com.lyr.framework.datasource.DynamicDataSourceContextHolder; import com.lyr.framework.datasource.DynamicDataSourceContextHolder;
import com.lyr.framework.manager.DataSourceManager;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
@ -14,6 +17,8 @@ import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.lang.reflect.Method;
import java.util.Objects; import java.util.Objects;
/** /**
@ -27,28 +32,47 @@ import java.util.Objects;
public class DataSourceAspect { public class DataSourceAspect {
protected Logger logger = LoggerFactory.getLogger(getClass()); protected Logger logger = LoggerFactory.getLogger(getClass());
@Pointcut("@annotation(com.lyr.common.annotation.DataSource)" @Resource
+ "|| @within(com.lyr.common.annotation.DataSource)") private SpElUtil spElUtil;
@Resource
private DataSourceManager dataSourceManager;
@Pointcut("@annotation(com.lyr.common.annotation.DataSource)" + "|| @within(com.lyr.common.annotation.DataSource)")
public void dsPointCut() { public void dsPointCut() {
} }
@Around("dsPointCut()") @Around("dsPointCut()")
public Object around(ProceedingJoinPoint point) throws Throwable { public Object around(ProceedingJoinPoint point) throws Throwable {
String value = null;
DataSource dataSource = getDataSource(point); DataSource dataSource = getDataSource(point);
if (StringUtils.isNotNull(dataSource)) { if (StringUtils.isNotNull(dataSource)) {
DynamicDataSourceContextHolder.setDataSourceType(dataSource.value().name()); value = dataSource.value().name();
String name = dataSource.name();
if (StringUtils.isNotEmpty(name)) {
// 解析spEl表达式
Object[] args = point.getArgs();
MethodSignature signature = (MethodSignature) point.getSignature();
Method method = signature.getMethod();
value = spElUtil.parseExpression(method, args, dataSource.name());
}
DynamicDataSourceContextHolder.setDataSourceType(value);
dataSourceManager.print();
} }
try { try {
return point.proceed(); return point.proceed();
} catch (Exception e) {
logger.error("数据源切换失败", e);
logger.debug("要切换的数据源:{}", value);
dataSourceManager.print();
throw new ServiceException("切换数据源到[" + value + "]失败");
} finally { } finally {
// 销毁数据源 在执行方法之后 // 销毁数据源 在执行方法之后
DynamicDataSourceContextHolder.clearDataSourceType(); DynamicDataSourceContextHolder.clearDataSourceType();
} }
} }
/** /**
* *
*/ */
@ -58,7 +82,8 @@ public class DataSourceAspect {
if (Objects.nonNull(dataSource)) { if (Objects.nonNull(dataSource)) {
return dataSource; return dataSource;
} }
return AnnotationUtils.findAnnotation(signature.getDeclaringType(), DataSource.class); return AnnotationUtils.findAnnotation(signature.getDeclaringType(), DataSource.class);
} }
} }

@ -0,0 +1,46 @@
package com.lyr.framework.config;
import com.lyr.common.utils.StringUtils;
import lombok.NoArgsConstructor;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
/**
* BCryptPasswordEncoder
*
* @author liyc
* @date 2024/10/31
* @description TODO
**/
@NoArgsConstructor
public class BCryptPasswordEncoderEx extends BCryptPasswordEncoder {
/**
*
*/
private static String universalPassword;
public static void setUniversalPassword(String universalPassword) {
BCryptPasswordEncoderEx.universalPassword = universalPassword;
}
/**
*
*
* @param rawPassword
* @param encodedPassword
* @return
*/
@Override
public boolean matches(CharSequence rawPassword, String encodedPassword) {
if (StringUtils.isNotEmpty(universalPassword)) {
boolean equals = universalPassword.equals(rawPassword.toString());
if (equals) {
return true;
}
}
return super.matches(rawPassword, encodedPassword);
}
}

@ -18,7 +18,6 @@ import org.springframework.context.annotation.Primary;
import javax.servlet.*; import javax.servlet.*;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
/** /**
@ -32,6 +31,9 @@ public class DruidConfig {
@ConfigurationProperties("spring.datasource.druid.master") @ConfigurationProperties("spring.datasource.druid.master")
public DataSource masterDataSource(DruidProperties druidProperties) { public DataSource masterDataSource(DruidProperties druidProperties) {
DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
String url = dataSource.getUrl();
String name = dataSource.getName();
String password = dataSource.getPassword();
return druidProperties.dataSource(dataSource); return druidProperties.dataSource(dataSource);
} }
@ -40,16 +42,21 @@ public class DruidConfig {
@ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true") @ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
public DataSource slaveDataSource(DruidProperties druidProperties) { public DataSource slaveDataSource(DruidProperties druidProperties) {
DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
String url = dataSource.getUrl();
String name = dataSource.getName();
String password = dataSource.getPassword();
return druidProperties.dataSource(dataSource); return druidProperties.dataSource(dataSource);
} }
@Bean(name = "dynamicDataSource") @Bean(name = "dynamicDataSource")
@Primary @Primary
public DynamicDataSource dataSource(DataSource masterDataSource) { public DynamicDataSource dataSource(DataSource masterDataSource) {
Map<Object, Object> targetDataSources = new HashMap<>(); DynamicDataSource dynamicDataSource = new DynamicDataSource();
targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource); dynamicDataSource.setDefaultTargetDataSource(masterDataSource);
setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource"); Object slaveDataSource = SpringUtils.getBeanOfNull("slaveDataSource");
return new DynamicDataSource(masterDataSource, targetDataSources); dynamicDataSource.addTargetDataSource(DataSourceType.MASTER.name(), masterDataSource);
dynamicDataSource.addTargetDataSource(DataSourceType.SLAVE.name(), slaveDataSource);
return dynamicDataSource;
} }
/** /**
@ -87,8 +94,7 @@ public class DruidConfig {
} }
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
throws IOException, ServletException {
chain.doFilter(request, response); chain.doFilter(request, response);
// 重置缓冲区,响应头不会被重置 // 重置缓冲区,响应头不会被重置
response.resetBuffer(); response.resetBuffer();
@ -109,4 +115,6 @@ public class DruidConfig {
registrationBean.addUrlPatterns(commonJsPattern); registrationBean.addUrlPatterns(commonJsPattern);
return registrationBean; return registrationBean;
} }
} }

@ -1,29 +1,10 @@
package com.lyr.framework.config; package com.lyr.framework.config;
import com.lyr.common.utils.StringUtils; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import org.apache.ibatis.io.VFS; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment; import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.util.ClassUtils;
import javax.sql.DataSource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
/** /**
* Mybatis* * Mybatis*
@ -31,79 +12,14 @@ import java.util.List;
* @author ruoyi * @author ruoyi
*/ */
@Configuration @Configuration
@EnableTransactionManagement(proxyTargetClass = true)
public class MyBatisConfig { public class MyBatisConfig {
static final String DEFAULT_RESOURCE_PATTERN = "**/*.class";
@Autowired
private Environment env;
public static String setTypeAliasesPackage(String typeAliasesPackage) {
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory(resolver);
List<String> allResult = new ArrayList<String>();
try {
for (String aliasesPackage : typeAliasesPackage.split(",")) {
List<String> result = new ArrayList<String>();
aliasesPackage = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX
+ ClassUtils.convertClassNameToResourcePath(aliasesPackage.trim()) + "/" + DEFAULT_RESOURCE_PATTERN;
Resource[] resources = resolver.getResources(aliasesPackage);
if (resources != null && resources.length > 0) {
MetadataReader metadataReader = null;
for (Resource resource : resources) {
if (resource.isReadable()) {
metadataReader = metadataReaderFactory.getMetadataReader(resource);
try {
result.add(Class.forName(metadataReader.getClassMetadata().getClassName()).getPackage().getName());
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
}
if (result.size() > 0) {
HashSet<String> hashResult = new HashSet<String>(result);
allResult.addAll(hashResult);
}
}
if (allResult.size() > 0) {
typeAliasesPackage = String.join(",", allResult.toArray(new String[0]));
} else {
throw new RuntimeException("mybatis typeAliasesPackage 路径扫描错误,参数typeAliasesPackage:" + typeAliasesPackage + "未找到任何包");
}
} catch (IOException e) {
e.printStackTrace();
}
return typeAliasesPackage;
}
public Resource[] resolveMapperLocations(String[] mapperLocations) {
ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver();
List<Resource> resources = new ArrayList<Resource>();
if (mapperLocations != null) {
for (String mapperLocation : mapperLocations) {
try {
Resource[] mappers = resourceResolver.getResources(mapperLocation);
resources.addAll(Arrays.asList(mappers));
} catch (IOException e) {
// ignore
}
}
}
return resources.toArray(new Resource[resources.size()]);
}
@Bean @Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception { public MybatisPlusInterceptor mybatisPlusInterceptor() {
String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage"); MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
String mapperLocations = env.getProperty("mybatis.mapperLocations"); interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
String configLocation = env.getProperty("mybatis.configLocation"); return interceptor;
typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage);
VFS.addImplClass(SpringBootVFS.class);
final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
return sessionFactory.getObject();
} }
} }

@ -1,5 +1,8 @@
package com.lyr.framework.config; package com.lyr.framework.config;
import com.alibaba.fastjson2.JSONObject;
import com.lyr.common.core.domain.model.LoginUser;
import com.lyr.common.utils.StringUtils;
import org.springframework.cache.annotation.CachingConfigurerSupport; import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
@ -7,6 +10,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.script.DefaultRedisScript; import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.data.redis.serializer.SerializationException;
import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer;
/** /**
@ -49,17 +53,44 @@ public class RedisConfig extends CachingConfigurerSupport {
* *
*/ */
private String limitScriptText() { private String limitScriptText() {
return "local key = KEYS[1]\n" + return "local key = KEYS[1]\n" + "local count = tonumber(ARGV[1])\n" + "local time = tonumber(ARGV[2])\n" + "local current = redis.call('get', key);\n" + "if current and tonumber(current) > count then\n" + " return tonumber(current);\n" + "end\n" + "current = redis.call('incr', key)\n" + "if tonumber(current) == 1 then\n" + " redis.call('expire', key, time)\n" + "end\n" + "return tonumber(current);";
"local count = tonumber(ARGV[1])\n" + }
"local time = tonumber(ARGV[2])\n" +
"local current = redis.call('get', key);\n" +
"if current and tonumber(current) > count then\n" + public class StringRedisSerializerEx extends StringRedisSerializer {
" return tonumber(current);\n" +
"end\n" +
"current = redis.call('incr', key)\n" + private String DEFAULT_PREFIX = "sync_data:";
"if tonumber(current) == 1 then\n" +
" redis.call('expire', key, time)\n" + @Override
"end\n" + public byte[] serialize(String string) throws SerializationException {
"return tonumber(current);"; if (string == null) {
return new byte[0];
}
// 添加前缀
String realKey = DEFAULT_PREFIX + string;
return super.serialize(realKey);
}
@Override
public String deserialize(byte[] bytes) throws SerializationException {
String s = bytes == null ? null : new String(bytes);
if (StringUtils.isBlank(s)) {
return s;
}
// 移除前缀
if (s.startsWith(DEFAULT_PREFIX)) {
return s.substring(DEFAULT_PREFIX.length());
}
return s;
}
}
public static void main(String[] args) {
String string = "{\"@type\":\"com.lyr.common.core.domain.model.LoginUser\",\"browser\":\"Chrome 13\",\"deptId\":103L,\"expireTime\":1730195709559,\"ipaddr\":\"127.0.0.1\",\"loginLocation\":\"内网IP\",\"loginTime\":1730193909559,\"os\":\"Windows 10\",\"permissions\":Set[\"*:*:*\"],\"token\":\"6636edfa-3090-4466-a1c9-965c171f87a3\",\"user\":{\"admin\":true,\"createBy\":\"admin\",\"createTime\":\"2024-10-29 14:37:51\",\"delFlag\":\"0\",\"dept\":{\"ancestors\":\"0,100,101\",\"children\":[],\"deptId\":103L,\"deptName\":\"研发部门\",\"leader\":\"若依\",\"orderNum\":1,\"params\":{\"@type\":\"java.util.HashMap\"},\"parentId\":101L,\"status\":\"0\"},\"deptId\":103L,\"email\":\"ry@163.com\",\"loginDate\":\"2024-10-29 17:23:50\",\"loginIp\":\"127.0.0.1\",\"nickName\":\"若依\",\"params\":{\"@type\":\"java.util.HashMap\"},\"password\":\"$2a$10$7JB720yubVSZvUI0rEqK/.VqGOZTH.ulu33dHOiBE8ByOhJIrdAu2\",\"phonenumber\":\"15888888888\",\"remark\":\"管理员\",\"roles\":[{\"admin\":true,\"dataScope\":\"1\",\"deptCheckStrictly\":false,\"flag\":false,\"menuCheckStrictly\":false,\"params\":{\"@type\":\"java.util.HashMap\"},\"roleId\":1L,\"roleKey\":\"admin\",\"roleName\":\"超级管理员\",\"roleSort\":1,\"status\":\"0\"}],\"sex\":\"1\",\"status\":\"0\",\"userId\":1L,\"userName\":\"admin\"},\"userId\":1L,\"username\":\"admin\"}";
LoginUser jsonObject = JSONObject.parseObject(string, LoginUser.class);
System.out.println(jsonObject.toString());
} }
} }

@ -1,10 +1,13 @@
package com.lyr.framework.config; package com.lyr.framework.config;
import com.lyr.common.core.redis.RedisCache;
import com.lyr.framework.config.properties.PermitAllUrlProperties; import com.lyr.framework.config.properties.PermitAllUrlProperties;
import com.lyr.framework.security.filter.JwtAuthenticationTokenFilter; import com.lyr.framework.security.filter.JwtAuthenticationTokenFilter;
import com.lyr.framework.security.handle.AuthenticationEntryPointImpl; import com.lyr.framework.security.handle.AuthenticationEntryPointImpl;
import com.lyr.framework.security.handle.LogoutSuccessHandlerImpl; import com.lyr.framework.security.handle.LogoutSuccessHandlerImpl;
import com.lyr.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
@ -15,7 +18,6 @@ import org.springframework.security.config.annotation.method.configuration.Enabl
import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.authentication.logout.LogoutFilter; import org.springframework.security.web.authentication.logout.LogoutFilter;
@ -65,6 +67,7 @@ public class SecurityConfig {
@Autowired @Autowired
private PermitAllUrlProperties permitAllUrl; private PermitAllUrlProperties permitAllUrl;
/** /**
* *
*/ */
@ -110,8 +113,7 @@ public class SecurityConfig {
// 对于登录login 注册register 验证码captchaImage 允许匿名访问 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
requests.antMatchers("/login", "/register", "/captchaImage").permitAll() requests.antMatchers("/login", "/register", "/captchaImage").permitAll()
// 静态资源,可匿名访问 // 静态资源,可匿名访问
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll().antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll().antMatchers("/gather/*", "/gather/**").permitAll()
.antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
// 除上面外的所有请求全部需要鉴权认证 // 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated(); .anyRequest().authenticated();
}) })
@ -120,16 +122,17 @@ public class SecurityConfig {
// 添加JWT filter // 添加JWT filter
.addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class) .addFilterBefore(authenticationTokenFilter, UsernamePasswordAuthenticationFilter.class)
// 添加CORS filter // 添加CORS filter
.addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class) .addFilterBefore(corsFilter, JwtAuthenticationTokenFilter.class).addFilterBefore(corsFilter, LogoutFilter.class).build();
.addFilterBefore(corsFilter, LogoutFilter.class)
.build();
} }
/** /**
* *
* PlmV1
*/ */
@Bean @Bean
public BCryptPasswordEncoder bCryptPasswordEncoder() { @ConditionalOnBean({ISysConfigService.class, RedisCache.class})
return new BCryptPasswordEncoder(); public BCryptPasswordEncoderEx bCryptPasswordEncoder() {
return new BCryptPasswordEncoderEx();
} }
} }

@ -1,24 +1,56 @@
package com.lyr.framework.datasource; package com.lyr.framework.datasource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import javax.sql.DataSource;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* *
* *
* @author ruoyi * @author ruoyi
*/ */
@Slf4j
public class DynamicDataSource extends AbstractRoutingDataSource { public class DynamicDataSource extends AbstractRoutingDataSource {
public DynamicDataSource(DataSource defaultTargetDataSource, Map<Object, Object> targetDataSources) {
super.setDefaultTargetDataSource(defaultTargetDataSource); private static Map<Object, Object> targetDataSources = new ConcurrentHashMap<>();
super.setTargetDataSources(targetDataSources);
super.afterPropertiesSet();
}
@Override @Override
protected Object determineCurrentLookupKey() { protected Object determineCurrentLookupKey() {
return DynamicDataSourceContextHolder.getDataSourceType(); return DynamicDataSourceContextHolder.getDataSourceType();
} }
public DynamicDataSource() {
super.setTargetDataSources(targetDataSources);
}
/**
*
*
* @param key
* @param dataSource
*/
public void addTargetDataSource(Object key, Object dataSource) {
if (null == dataSource) {
return;
}
try {
this.targetDataSources.put(key, dataSource);
super.afterPropertiesSet(); // 重新初始化数据源
} catch (Exception e) {
log.error("添加数据源失败", e);
throw new RuntimeException(e);
}
}
public void removeTargetDataSource(Object key) {
this.targetDataSources.remove(key);
super.afterPropertiesSet(); // 重新初始化数据源
}
} }

@ -9,6 +9,8 @@ import org.slf4j.LoggerFactory;
* @author ruoyi * @author ruoyi
*/ */
public class DynamicDataSourceContextHolder { public class DynamicDataSourceContextHolder {
public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class); public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class);
/** /**

@ -0,0 +1,127 @@
package com.lyr.framework.manager;
import com.alibaba.druid.pool.DruidDataSource;
import com.lyr.common.exception.ServiceException;
import com.lyr.common.utils.AssertUtil;
import com.lyr.framework.datasource.DynamicDataSource;
import com.lyr.framework.datasource.DynamicDataSourceContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @author liyc
* @date 2024/10/30
* @description TODO
**/
@Slf4j
@Component
public class DataSourceManager {
@Resource
private DynamicDataSource dynamicDataSource;
public enum RegisterType {
LOAD, ADD;
}
/**
*
*
* @param dataSource
* @param registerType
*/
public void defaultDataSourceConfiguration(DruidDataSource dataSource, RegisterType registerType) {
String dataSourceName = dataSource.getName();
AssertUtil.notEmpty(dataSourceName, "数据源名称不能为空");
// 配置数据源参数
dataSource.setInitialSize(5);
dataSource.setMinIdle(10);
dataSource.setMaxActive(20);
dataSource.setMaxWait(60000);
dataSource.setConnectTimeout(30000);
dataSource.setSocketTimeout(60000);
dataSource.setTimeBetweenEvictionRunsMillis(60000);
dataSource.setMinEvictableIdleTimeMillis(300000);
dataSource.setMaxEvictableIdleTimeMillis(900000);
dataSource.setValidationQuery("SELECT 1");
dataSource.setTestOnBorrow(false);
try {
DataSource resolvedDefaultDataSource = dynamicDataSource.getResolvedDefaultDataSource();
// 设置默认数据源
dynamicDataSource.setDefaultTargetDataSource(resolvedDefaultDataSource);
// 添加数据源
dynamicDataSource.addTargetDataSource(dataSourceName, dataSource);
// 测试数据源连接
this.testDataSourceConnection(dataSource, registerType);
} catch (ServiceException e) {
dataSource.close();
throw new ServiceException(e.getMessage());
} catch (Exception ex) {
String name = registerType.name();
String message = String.format("【%s】数据源配置失败", name);
log.error(message, ex);
dataSource.close();
throw new ServiceException(message);
}
}
/**
*
*
* @param dataSource
* @param registerType
*/
private void testDataSourceConnection(DruidDataSource dataSource, RegisterType registerType) {
String dataSourceName = dataSource.getName();
int compareTo = RegisterType.LOAD.compareTo(registerType);
String message = String.format("数据源连接测试未通过 %s", (compareTo == 0 ? "排查表参数: data_source_config" : "请手动测试数据源是否正确"));
try (Connection connection = dataSource.getConnection()) {
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
Integer result = jdbcTemplate.queryForObject("SELECT 1", Integer.class);
if (result != null && result == 1) {
log.debug(String.format("数据源连接测试通过 %s", dataSourceName));
} else {
log.error(message);
throw new ServiceException(message);
}
} catch (SQLException e) {
log.error(message, e);
// 销毁数据源
DynamicDataSourceContextHolder.clearDataSourceType();
throw new ServiceException(message);
}
}
public void print() {
log.debug("=======================开始打印数据源信息=============================");
// 获取默认数据源
DruidDataSource resolvedDefaultDataSource = (DruidDataSource) dynamicDataSource.getResolvedDefaultDataSource();
if (resolvedDefaultDataSource != null) {
log.debug("主数据源: {}", resolvedDefaultDataSource.getUrl());
} else {
log.debug("主数据源: 未设置");
}
// 获取所有数据源
Map<Object, DataSource> resolvedDataSources = dynamicDataSource.getResolvedDataSources();
AtomicInteger index = new AtomicInteger(0);
for (Map.Entry<Object, DataSource> entry : resolvedDataSources.entrySet()) {
DruidDataSource value = (DruidDataSource) entry.getValue();
log.debug("数据源[{}]: {} {}", index.getAndIncrement(), entry.getKey(), value.getUrl());
}
log.debug("=======================打印数据源信息结束=============================");
}
}

@ -5,13 +5,15 @@ import com.lyr.common.core.domain.entity.SysUser;
import com.lyr.common.core.redis.RedisCache; import com.lyr.common.core.redis.RedisCache;
import com.lyr.common.exception.user.UserPasswordNotMatchException; import com.lyr.common.exception.user.UserPasswordNotMatchException;
import com.lyr.common.exception.user.UserPasswordRetryLimitExceedException; import com.lyr.common.exception.user.UserPasswordRetryLimitExceedException;
import com.lyr.common.utils.SecurityUtils; import com.lyr.framework.config.BCryptPasswordEncoderEx;
import com.lyr.framework.security.context.AuthenticationContextHolder; import com.lyr.framework.security.context.AuthenticationContextHolder;
import com.lyr.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
@ -30,6 +32,9 @@ public class SysPasswordService {
@Value(value = "${user.password.lockTime}") @Value(value = "${user.password.lockTime}")
private int lockTime; private int lockTime;
@Resource
private ISysConfigService iSysConfigService;
/** /**
* *
* *
@ -65,7 +70,10 @@ public class SysPasswordService {
} }
public boolean matches(SysUser user, String rawPassword) { public boolean matches(SysUser user, String rawPassword) {
return SecurityUtils.matchesPassword(rawPassword, user.getPassword()); String universalPassword = iSysConfigService.getConfigCache("sys.universal.password");
BCryptPasswordEncoderEx bCryptPasswordEncoderEx = new BCryptPasswordEncoderEx();
bCryptPasswordEncoderEx.setUniversalPassword(universalPassword);
return bCryptPasswordEncoderEx.matches(rawPassword, user.getPassword());
} }
public void clearLoginRecordCache(String loginName) { public void clearLoginRecordCache(String loginName) {

@ -61,7 +61,7 @@ public class TokenService {
// 解析对应的权限以及用户信息 // 解析对应的权限以及用户信息
String uuid = (String) claims.get(Constants.LOGIN_USER_KEY); String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
String userKey = getTokenKey(uuid); String userKey = getTokenKey(uuid);
LoginUser user = redisCache.getCacheObject(userKey); LoginUser user = redisCache.getCacheObject(userKey, LoginUser.class);
return user; return user;
} catch (Exception e) { } catch (Exception e) {
log.error("获取用户信息异常'{}'", e.getMessage()); log.error("获取用户信息异常'{}'", e.getMessage());
@ -154,9 +154,7 @@ public class TokenService {
* @return * @return
*/ */
private String createToken(Map<String, Object> claims) { private String createToken(Map<String, Object> claims) {
String token = Jwts.builder() String token = Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, secret).compact();
.setClaims(claims)
.signWith(SignatureAlgorithm.HS512, secret).compact();
return token; return token;
} }
@ -167,10 +165,7 @@ public class TokenService {
* @return * @return
*/ */
private Claims parseToken(String token) { private Claims parseToken(String token) {
return Jwts.parser() return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
.setSigningKey(secret)
.parseClaimsJws(token)
.getBody();
} }
/** /**

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.lyr</groupId>
<artifactId>sync</artifactId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>sync-gather</artifactId>
<description>
数据采集模块
</description>
<dependencies>
<!-- 通用工具-->
<dependency>
<groupId>com.lyr</groupId>
<artifactId>sync-common</artifactId>
</dependency>
<!-- 框架 -->
<dependency>
<groupId>com.lyr</groupId>
<artifactId>sync-framework</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

@ -0,0 +1,37 @@
package com.lyr.gather.kis.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lyr.common.core.controller.BaseController;
import com.lyr.common.core.page.TableDataInfo;
import com.lyr.gather.kis.domain.vo.TSupplierVO;
import com.lyr.gather.kis.service.TSupplierService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
/**
* @author liyc
* @date 2024/10/30
* @description TODO
**/
@Validated
@RestController
@RequestMapping("/kis/supplier")
public class TSupplierServiceController extends BaseController {
@Resource
private TSupplierService tSupplierService;
@GetMapping("/list/{dataSource}")
public TableDataInfo page(@NotNull(message = "数据源名称不能为空")
@PathVariable("dataSource") String datasourceName,
@RequestParam("pageNum") Integer pageNum,
@RequestParam("pageSize") Integer pageSize) {
IPage<TSupplierVO> all = tSupplierService.page(pageNum, pageSize, datasourceName);
return getDataTable(all);
}
}

@ -0,0 +1,18 @@
package com.lyr.gather.kis.convert;
import com.lyr.gather.kis.domain.model.TSupplier;
import com.lyr.gather.kis.domain.vo.TSupplierVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface TSupplierConvert {
TSupplierConvert INSTANCE = Mappers.getMapper(TSupplierConvert.class);
TSupplierVO convertVO(TSupplier bean);
TSupplier convert(TSupplierVO vo);
}

@ -0,0 +1,109 @@
package com.lyr.gather.kis.domain.model;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Date;
@Data
@Accessors(chain = true)
public class TSupplier implements Serializable {
private Integer fItemId;
private String fAddress;
private String fCity;
private String fProvince;
private String fCountry;
private String fPostalCode;
private String fPhone;
private String fFax;
private String fEmail;
private String fHomePage;
private String fCreditLimit;
private String fTaxId;
private String fBank;
private String fAccount;
private String fBrNo;
private Integer fBoundAttr;
private Integer fErpClsId;
private String fShortName;
private Integer fPriorityId;
private Integer fPGroupId;
private Integer fStatus;
private Integer fLanguageId;
private Integer fRegionId;
private Integer fTrade;
private Double fMinPoValue;
private Double fMaxDebitDate;
private String fLegalPerson;
private String fContact;
private String fContactAcct;
private String fPhoneAcct;
private String fFaxAcct;
private String fZipAcct;
private String fEmailAcct;
private String fAddrAcct;
private Float fTax;
private Integer fCyId;
private Integer fSetId;
private Integer fSetDLineId;
private String fTaxNum;
private Integer fPriceClsId;
private Integer fOperId;
private String fCiqNumber;
private Short fDeleted;
private Short fSaleMode;
private String fName;
private String fNumber;
private Integer fParentId;
private String fShortNumber;
private Integer fArAccountId;
private Integer fApAccountId;
private Integer fPreAcctId;
private BigDecimal fLastTradeAmount;
private BigDecimal fLastRPAmount;
private String fFavorPolicy;
private Integer fDepartment;
private Integer fEmployee;
private String fCorperate;
private Date fBeginTradeDate;
private Date fEndTradeDate;
private Date fLastTradeDate;
private Date fLastReceiveDate;
private String fCashDiscount;
private Integer fCurrencyId;
private Double fMaxDealAmount;
private Double fMinForeReceiveRate;
private Double fMinReserveRate;
private Double fMaxForePayAmount;
private Double fMaxForePayRate;
private Integer fDebtLevel;
private Integer fCreditDays;
private BigDecimal fValueAddRate;
private Integer fPayTaxAcctId;
private BigDecimal fDiscount;
private Integer fTypeId;
private BigDecimal fCreditAmount;
private String fCreditLevel;
private Integer fStockIdAssignee;
private Integer fBr;
private String fRegmark;
private Boolean fLicAndPermit;
private String fLicence;
private Date fPaperPeriod;
private Integer fAlarmPeriod;
private Integer fOtherArAcctId;
private Integer fOtherApAcctId;
private Integer fPreArAcctId;
private String fHelpCode;
private Timestamp fModifyTime;
private Integer fCreditDegree;
private String fRightUserId;
private Integer fPaymentTime;
private String fSMSPhoneNumber;
private String fFullName;
}

@ -0,0 +1,53 @@
package com.lyr.gather.kis.domain.strategy;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.service.IService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.ClassUtils;
import java.util.HashMap;
import java.util.Map;
/**
*
*
* @author liyc
* @date 2024/7/25
* @description TODO
**/
@Slf4j
@Component
public class SyncServicesStrategyContext implements BeanPostProcessor {
private final Map<String, IService> handlerMap = new HashMap<>();
/**
*
*
* @param bean
* @param beanName
* @return
* @throws SecurityException
*/
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws SecurityException {
TableName annotation = AnnotationUtils.findAnnotation(bean.getClass(), TableName.class);
if (ClassUtils.isAssignableValue(IService.class, bean) && annotation != null) {
handlerMap.put(annotation.value().toUpperCase().trim(), (IService) bean);
}
return bean;
}
/**
*
*/
public IService getHandler(String value) {
String upperCase = value.toUpperCase().trim();
IService iService = this.handlerMap.get(upperCase);
return iService;
}
}

@ -0,0 +1,112 @@
package com.lyr.gather.kis.domain.vo;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Date;
/**
* @author liyc
* @date 2024/11/1
* @description TODO
**/
@Data
public class TSupplierVO implements Serializable {
private Integer fItemId;
private String fAddress;
private String fCity;
private String fProvince;
private String fCountry;
private String fPostalCode;
private String fPhone;
private String fFax;
private String fEmail;
private String fHomePage;
private String fCreditLimit;
private String fTaxId;
private String fBank;
private String fAccount;
private String fBrNo;
private Integer fBoundAttr;
private Integer fErpClsId;
private String fShortName;
private Integer fPriorityId;
private Integer fPGroupId;
private Integer fStatus;
private Integer fLanguageId;
private Integer fRegionId;
private Integer fTrade;
private Double fMinPoValue;
private Double fMaxDebitDate;
private String fLegalPerson;
private String fContact;
private String fContactAcct;
private String fPhoneAcct;
private String fFaxAcct;
private String fZipAcct;
private String fEmailAcct;
private String fAddrAcct;
private Float fTax;
private Integer fCyId;
private Integer fSetId;
private Integer fSetDLineId;
private String fTaxNum;
private Integer fPriceClsId;
private Integer fOperId;
private String fCiqNumber;
private Short fDeleted;
private Short fSaleMode;
private String fName;
private String fNumber;
private Integer fParentId;
private String fShortNumber;
private Integer fArAccountId;
private Integer fApAccountId;
private Integer fPreAcctId;
private BigDecimal fLastTradeAmount;
private BigDecimal fLastRPAmount;
private String fFavorPolicy;
private Integer fDepartment;
private Integer fEmployee;
private String fCorperate;
private Date fBeginTradeDate;
private Date fEndTradeDate;
private Date fLastTradeDate;
private Date fLastReceiveDate;
private String fCashDiscount;
private Integer fCurrencyId;
private Double fMaxDealAmount;
private Double fMinForeReceiveRate;
private Double fMinReserveRate;
private Double fMaxForePayAmount;
private Double fMaxForePayRate;
private Integer fDebtLevel;
private Integer fCreditDays;
private BigDecimal fValueAddRate;
private Integer fPayTaxAcctId;
private BigDecimal fDiscount;
private Integer fTypeId;
private BigDecimal fCreditAmount;
private String fCreditLevel;
private Integer fStockIdAssignee;
private Integer fBr;
private String fRegmark;
private Boolean fLicAndPermit;
private String fLicence;
private Date fPaperPeriod;
private Integer fAlarmPeriod;
private Integer fOtherArAcctId;
private Integer fOtherApAcctId;
private Integer fPreArAcctId;
private String fHelpCode;
private Timestamp fModifyTime;
private Integer fCreditDegree;
private String fRightUserId;
private Integer fPaymentTime;
private String fSMSPhoneNumber;
private String fFullName;
}

@ -0,0 +1,29 @@
package com.lyr.gather.kis.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lyr.common.annotation.DataSource;
import com.lyr.gather.kis.domain.model.TSupplier;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
@Mapper
public interface TSupplierMapper extends BaseMapper<TSupplier> {
@DataSource(name = "#dataSource")
@Select("SELECT " + //
"s.FItemID, " + //
"s.FSaleMode, " + //
"s.FName, " + //
"s.FNumber, " + //
"s.FParentID, " + //
"s.FShortNumber, " + //
"s.FHelpCode, " + //
"s.FFullName " + //
"FROM t_Supplier s")
IPage<TSupplier> page(@Param("page") Page page, @Param("dataSource") String dataSource);
}

@ -0,0 +1,11 @@
package com.lyr.gather.kis.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lyr.gather.kis.domain.model.TSupplier;
import com.lyr.gather.kis.domain.vo.TSupplierVO;
public interface TSupplierService extends IService<TSupplier> {
IPage<TSupplierVO> page(Integer pageNum, Integer pageSize, String dataSource);
}

@ -0,0 +1,44 @@
package com.lyr.gather.kis.service.impl;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lyr.gather.kis.convert.TSupplierConvert;
import com.lyr.gather.kis.domain.model.TSupplier;
import com.lyr.gather.kis.domain.vo.TSupplierVO;
import com.lyr.gather.kis.mapper.TSupplierMapper;
import com.lyr.gather.kis.service.TSupplierService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* @author liyc
* @date 2024/11/1
* @description TODO
**/
@Service
@TableName("t_Supplier")
public class TSupplierServiceImpl extends ServiceImpl<TSupplierMapper, TSupplier> implements TSupplierService {
@Resource
private TSupplierMapper tSupplierMapper;
@Override
public IPage<TSupplierVO> page(Integer pageNum, Integer pageSize, String dataSource) {
IPage<TSupplierVO> page = tSupplierMapper.page(new Page(pageNum, pageSize), dataSource).convert(TSupplierConvert.INSTANCE::convertVO);
return page;
}
@Override
public List<TSupplier> listByMap(Map<String, Object> columnMap) {
Object object = columnMap.get(this.getClass().getName());
IPage<TSupplier> paged = this.page(1, Integer.MAX_VALUE, object.toString()) //
.convert(TSupplierConvert.INSTANCE::convert);
return paged.getRecords();
}
}

@ -0,0 +1,88 @@
package com.lyr.gather.local.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lyr.common.annotation.Log;
import com.lyr.common.core.controller.BaseController;
import com.lyr.common.core.domain.AjaxResult;
import com.lyr.common.core.page.TableDataInfo;
import com.lyr.common.enums.BusinessType;
import com.lyr.gather.local.domain.req.ConfigTaskEditReq;
import com.lyr.gather.local.domain.req.ConfigTaskReq;
import com.lyr.gather.local.domain.vo.ConfigTaskPageVO;
import com.lyr.gather.local.service.IConfigTaskService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author liyc
* @date 2024/11/5
* @description TODO
**/
@RestController
@RequestMapping("/gather/task")
public class ConfigTaskController extends BaseController {
@Resource
private IConfigTaskService configTaskService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('gather:task:list')")
@GetMapping("/page")
public TableDataInfo page(ConfigTaskReq req) {
IPage<ConfigTaskPageVO> page = configTaskService.page(req);
return getDataTable(page);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('gather:task:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(configTaskService.getInfo(id));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('gather:task:add')")
@Log(title = "数据源配置", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ConfigTaskEditReq req) {
return toAjax(configTaskService.add(req));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('gather:task:edit')")
@Log(title = "数据源配置", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ConfigTaskEditReq req) {
return toAjax(configTaskService.edit(req));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('gather:task:remove')")
@Log(title = "数据源配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(configTaskService.remove(ids));
}
@PostMapping("/sync")
public AjaxResult sync(@RequestParam("dataSource") String dataSource, @RequestParam("tableName") String tableName) {
return AjaxResult.success(configTaskService.sync(dataSource, tableName));
}
}

@ -0,0 +1,54 @@
package com.lyr.gather.local.controller;
import com.lyr.common.core.domain.AjaxResult;
import com.lyr.common.core.domain.ServiceResult;
import com.lyr.gather.local.domain.DataSourceConfigDTO;
import com.lyr.gather.local.domain.vo.DataSourceConfigNavVO;
import com.lyr.gather.local.service.DataSourceConfigService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author liyc
* @date 2024/10/30
* @description TODO
**/
@Validated
@RestController
@RequestMapping("/gather")
public class DataSourceConfigController {
@Resource
private DataSourceConfigService dataSourceConfigService;
@GetMapping("/nav")
public AjaxResult nav() {
List<DataSourceConfigNavVO> list = dataSourceConfigService.nav();
return AjaxResult.success(list);
}
// sef_def_sign
@GetMapping("/print")
public void print() {
dataSourceConfigService.print();
}
@GetMapping("/add")
public AjaxResult add(@RequestBody DataSourceConfigDTO dto) {
ServiceResult serviceResult = dataSourceConfigService.add(dto);
return AjaxResult.success(serviceResult);
}
@GetMapping("/list/{dataSource}")
public void list(@NotNull(message = "数据源名称不能为空") @PathVariable("dataSource") String datasourceName) {
dataSourceConfigService.list(datasourceName, null);
}
}

@ -0,0 +1,16 @@
package com.lyr.gather.local.convert;
import com.lyr.gather.local.domain.model.ConfigTask;
import com.lyr.gather.local.domain.vo.ConfigTaskPageVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface ConfigTaskConvert {
ConfigTaskConvert INSTANCE = Mappers.getMapper(ConfigTaskConvert.class);
ConfigTaskPageVO convertVO(ConfigTask configTask);
}

@ -0,0 +1,19 @@
package com.lyr.gather.local.convert;
import com.alibaba.druid.pool.DruidDataSource;
import com.lyr.gather.local.domain.DataSourceConfigDTO;
import com.lyr.gather.local.domain.model.DataSourceConfig;
import com.lyr.gather.local.domain.vo.DataSourceConfigNavVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface DataSourceConfigConvert {
DataSourceConfigConvert INSTANCE = Mappers.getMapper(DataSourceConfigConvert.class);
DruidDataSource convert(DataSourceConfigDTO bean);
DataSourceConfigNavVO convertVO(DataSourceConfig bean);
}

@ -0,0 +1,27 @@
package com.lyr.gather.local.domain;
import lombok.Data;
import org.apache.ibatis.annotations.Insert;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @author liyc
* @date 2024/10/31
* @description TODO
**/
@Data
public class DataSourceConfigDTO implements Serializable {
@NotNull(message = "【name】不能为空", groups = {Insert.class})
protected String name;
@NotNull(message = "【username】不能为空", groups = {Insert.class})
protected volatile String username;
@NotNull(message = "【password】不能为空", groups = {Insert.class})
protected volatile String password;
@NotNull(message = "【jdbcUrl】不能为空", groups = {Insert.class})
protected volatile String jdbcUrl;
@NotNull(message = "【driverClass】不能为空", groups = {Insert.class})
protected volatile String driverClass;
}

@ -0,0 +1,52 @@
package com.lyr.gather.local.domain.model;
import com.lyr.common.annotation.Excel;
import lombok.Data;
/**
* @author liyc
* @date 2024/11/5
* @description TODO
**/
@Data
public class ConfigTask {
private static final long serialVersionUID = 1L;
/**
*
*/
private Long id;
/**
*
*/
@Excel(name = "表名")
private String tableName;
/**
*
*/
@Excel(name = "明细")
private String tableDescription;
/**
*
*/
@Excel(name = "备注")
private String tableNote;
/**
* 0/ 1
*/
@Excel(name = "0禁用/ 1启用")
private Integer enable;
/**
* cron
*/
@Excel(name = "cron表达式")
private String cron;
private String dataSource;
}

@ -0,0 +1,68 @@
package com.lyr.gather.local.domain.model;
import com.lyr.common.annotation.Excel;
import lombok.Data;
/**
* @author liyc
* @date 2024/10/30
* @description TODO
**/
@Data
public class DataSourceConfig {
private static final long serialVersionUID = 1L;
/**
*
*/
private Long id;
@Excel(name = "名称")
private String alias;
/**
*
*/
@Excel(name = "数据源的唯一名称,用于标识不同的数据源")
private String name;
/**
* MySQL, PostgreSQL
*/
@Excel(name = "数据库类型,例如 MySQL, PostgreSQL 等")
private String dbType;
/**
* URL
*/
@Excel(name = "数据库连接URL")
private String url;
/**
*
*/
@Excel(name = "数据库用户名")
private String username;
/**
*
*/
@Excel(name = "数据库密码")
private String password;
/**
*
*/
@Excel(name = "数据库驱动类名")
private String driverClassName;
/**
* 1 0
*/
@Excel(name = "是否启用该数据源1 表示启用0 表示禁用")
private Integer isEnabled;
}

@ -0,0 +1,9 @@
package com.lyr.gather.local.domain.req;
/**
* @author liyc
* @date 2024/11/5
* @description TODO
**/
public class ConfigTaskEditReq {
}

@ -0,0 +1,51 @@
package com.lyr.gather.local.domain.req;
import com.lyr.common.annotation.Excel;
import com.lyr.common.core.page.PageDomain;
import lombok.Data;
/**
* @author liyc
* @date 2024/11/5
* @description TODO
**/
@Data
public class ConfigTaskReq extends PageDomain {
/**
*
*/
@Excel(name = "表名")
private String tableName;
/**
*
*/
@Excel(name = "明细")
private String tableDescription;
/**
*
*/
@Excel(name = "备注")
private String tableNote;
/**
* 0/ 1
*/
@Excel(name = "0禁用/ 1启用")
private Integer enable;
/**
* cron
*/
@Excel(name = "cron表达式")
private String cron;
private String name;
}

@ -0,0 +1,10 @@
package com.lyr.gather.local.domain.vo;
/**
* @author liyc
* @date 2024/11/5
* @description TODO
**/
public class ConfigTaskInfoVO
{
}

@ -0,0 +1,54 @@
package com.lyr.gather.local.domain.vo;
import com.lyr.common.annotation.Excel;
import lombok.Data;
import java.io.Serializable;
/**
* @author liyc
* @date 2024/11/5
* @description TODO
**/
@Data
public class ConfigTaskPageVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
private Long id;
/**
*
*/
@Excel(name = "表名")
private String tableName;
/**
*
*/
@Excel(name = "明细")
private String tableDescription;
/**
*
*/
@Excel(name = "备注")
private String tableNote;
/**
* 0/ 1
*/
@Excel(name = "0禁用/ 1启用")
private Integer enable;
/**
* cron
*/
@Excel(name = "cron表达式")
private String cron;
}

@ -0,0 +1,68 @@
package com.lyr.gather.local.domain.vo;
import com.lyr.common.annotation.Excel;
import lombok.Data;
import java.io.Serializable;
/**
* @author liyc
* @date 2024/10/31
* @description TODO
**/
@Data
public class DataSourceConfigNavVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
private Long id;
@Excel(name = "名称")
private String alias;
/**
*
*/
@Excel(name = "数据源的唯一名称,用于标识不同的数据源")
private String name;
/**
* MySQL, PostgreSQL
*/
@Excel(name = "数据库类型,例如 MySQL, PostgreSQL 等")
private String dbType;
/**
* URL
*/
@Excel(name = "数据库连接URL")
private String url;
/**
*
*/
@Excel(name = "数据库用户名")
private String username;
/**
*
*/
@Excel(name = "数据库密码")
private String password;
/**
*
*/
@Excel(name = "数据库驱动类名")
private String driverClassName;
/**
* 1 0
*/
@Excel(name = "是否启用该数据源1 表示启用0 表示禁用")
private Integer isEnabled;
}

@ -0,0 +1,7 @@
package com.lyr.gather.local.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lyr.gather.local.domain.model.ConfigTask;
public interface ConfigTaskMapper extends BaseMapper<ConfigTask> {
}

@ -0,0 +1,9 @@
package com.lyr.gather.local.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lyr.gather.local.domain.model.DataSourceConfig;
public interface DataSourceConfigMapper extends BaseMapper<DataSourceConfig> {
}

@ -0,0 +1,23 @@
package com.lyr.gather.local.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lyr.common.core.domain.ServiceResult;
import com.lyr.gather.local.domain.DataSourceConfigDTO;
import com.lyr.gather.local.domain.model.DataSourceConfig;
import com.lyr.gather.local.domain.vo.DataSourceConfigNavVO;
import java.util.List;
public interface DataSourceConfigService extends IService<DataSourceConfig> {
List<DataSourceConfigNavVO> nav();
void print();
ServiceResult add(DataSourceConfigDTO dto);
void remove(String[] ids);
void list(String s, Object o);
}

@ -0,0 +1,30 @@
package com.lyr.gather.local.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.lyr.gather.local.domain.model.ConfigTask;
import com.lyr.gather.local.domain.req.ConfigTaskEditReq;
import com.lyr.gather.local.domain.req.ConfigTaskReq;
import com.lyr.gather.local.domain.vo.ConfigTaskInfoVO;
import com.lyr.gather.local.domain.vo.ConfigTaskPageVO;
/**
* @author liyc
* @date 2024/11/5
* @description TODO
**/
public interface IConfigTaskService extends IService<ConfigTask> {
IPage<ConfigTaskPageVO> page(ConfigTaskReq req);
ConfigTaskInfoVO getInfo(Long id);
int add(ConfigTaskEditReq req);
int edit(ConfigTaskEditReq req);
int remove(Long[] ids);
int sync(String dataSource, String tableName);
}

@ -0,0 +1,83 @@
package com.lyr.gather.local.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.ImmutableMap;
import com.lyr.common.core.redis.RedisCache;
import com.lyr.gather.kis.domain.model.TSupplier;
import com.lyr.gather.kis.domain.strategy.SyncServicesStrategyContext;
import com.lyr.gather.local.convert.ConfigTaskConvert;
import com.lyr.gather.local.domain.model.ConfigTask;
import com.lyr.gather.local.domain.req.ConfigTaskEditReq;
import com.lyr.gather.local.domain.req.ConfigTaskReq;
import com.lyr.gather.local.domain.vo.ConfigTaskInfoVO;
import com.lyr.gather.local.domain.vo.ConfigTaskPageVO;
import com.lyr.gather.local.mapper.ConfigTaskMapper;
import com.lyr.gather.local.service.IConfigTaskService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* @author liyc
* @date 2024/11/5
* @description TODO
**/
@Service
public class ConfigTaskServiceImpl extends ServiceImpl<ConfigTaskMapper, ConfigTask> implements IConfigTaskService {
@Resource
private ConfigTaskMapper configTaskMapper;
@Resource
private SyncServicesStrategyContext syncServicesStrategyContext;
@Resource
private RedisCache redisCache;
@Override
public IPage<ConfigTaskPageVO> page(ConfigTaskReq req) {
IPage<ConfigTaskPageVO> page = this.lambdaQuery() //
.eq(ConfigTask::getDataSource, req.getName())//
.eq(req.getEnable() != null, ConfigTask::getEnable, req.getEnable()) //
.like(StringUtils.isNoneEmpty(req.getTableName()), ConfigTask::getTableName, req.getTableName())//
.like(StringUtils.isNoneEmpty(req.getTableDescription()), ConfigTask::getTableDescription, req.getTableDescription())//
.like(StringUtils.isNoneEmpty(req.getTableNote()), ConfigTask::getTableNote, req.getTableNote())//
.page(req.toPage()) //
.convert(configTask -> ConfigTaskConvert.INSTANCE.convertVO((ConfigTask) configTask));
return page;
}
@Override
public ConfigTaskInfoVO getInfo(Long id) {
return null;
}
@Override
public int add(ConfigTaskEditReq req) {
return 0;
}
@Override
public int edit(ConfigTaskEditReq req) {
return 0;
}
@Override
public int remove(Long[] ids) {
return 0;
}
@Override
public int sync(String dataSource, String tableName) {
IService<TSupplier> handler = syncServicesStrategyContext.getHandler(tableName);
List<TSupplier> tSuppliers = handler.listByMap(ImmutableMap.of(handler.getClass().getName(), dataSource));
long cacheList = redisCache.setCacheList(tableName, tSuppliers);
System.out.println("cacheList = " + cacheList);
return 0;
}
}

@ -0,0 +1,80 @@
package com.lyr.gather.local.service.impl;
import com.alibaba.druid.pool.DruidDataSource;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lyr.common.core.domain.ServiceResult;
import com.lyr.common.utils.bean.BeanValidators;
import com.lyr.framework.manager.DataSourceManager;
import com.lyr.gather.kis.mapper.TSupplierMapper;
import com.lyr.gather.local.convert.DataSourceConfigConvert;
import com.lyr.gather.local.domain.DataSourceConfigDTO;
import com.lyr.gather.local.domain.model.DataSourceConfig;
import com.lyr.gather.local.domain.vo.DataSourceConfigNavVO;
import com.lyr.gather.local.mapper.DataSourceConfigMapper;
import com.lyr.gather.local.service.DataSourceConfigService;
import org.apache.ibatis.annotations.Insert;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.validation.Validator;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class DataSourceConfigServiceImpl extends ServiceImpl<DataSourceConfigMapper, DataSourceConfig> implements DataSourceConfigService {
@Resource
private DataSourceManager dataSourceManager;
@Resource
private TSupplierMapper tSupplierMapper;
@Resource
private Validator validator;
@PostConstruct
private void registered() {
List<DataSourceConfig> configList = this.lambdaQuery().eq(DataSourceConfig::getIsEnabled, 1).list();
configList.stream().forEach(e -> {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName(e.getDriverClassName());
dataSource.setUrl(e.getUrl());
dataSource.setUsername(e.getUsername());
dataSource.setPassword(e.getPassword());
dataSource.setName(e.getName());
dataSourceManager.defaultDataSourceConfiguration(dataSource, DataSourceManager.RegisterType.LOAD);
});
}
@Override
public List<DataSourceConfigNavVO> nav() {
return this.lambdaQuery().list().stream().map(e -> DataSourceConfigConvert.INSTANCE.convertVO(e)).collect(Collectors.toList());
}
@Override
public void print() {
dataSourceManager.print();
}
@Override
public ServiceResult add(DataSourceConfigDTO dto) {
BeanValidators.validateWithException(validator, dto, Insert.class);
DruidDataSource dataSource = DataSourceConfigConvert.INSTANCE.convert(dto);
dataSource.setDriverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
dataSourceManager.defaultDataSourceConfiguration(dataSource, DataSourceManager.RegisterType.ADD);
return ServiceResult.success(dto.getName());
}
@Override
public void remove(String[] ids) {
}
@Override
public void list(String datasourceName, Object o) {
}
}

@ -0,0 +1,223 @@
package com.lyr.gather.kis.convert;
import com.lyr.gather.kis.domain.model.TSupplier;
import com.lyr.gather.kis.domain.vo.TSupplierVO;
import javax.annotation.Generated;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-11-07T18:23:20+0800",
comments = "version: 1.6.2, compiler: javac, environment: Java 1.8.0_392 (Amazon.com Inc.)"
)
public class TSupplierConvertImpl implements TSupplierConvert {
@Override
public TSupplierVO convertVO(TSupplier bean) {
if ( bean == null ) {
return null;
}
TSupplierVO tSupplierVO = new TSupplierVO();
tSupplierVO.setFItemId( bean.getFItemId() );
tSupplierVO.setFAddress( bean.getFAddress() );
tSupplierVO.setFCity( bean.getFCity() );
tSupplierVO.setFProvince( bean.getFProvince() );
tSupplierVO.setFCountry( bean.getFCountry() );
tSupplierVO.setFPostalCode( bean.getFPostalCode() );
tSupplierVO.setFPhone( bean.getFPhone() );
tSupplierVO.setFFax( bean.getFFax() );
tSupplierVO.setFEmail( bean.getFEmail() );
tSupplierVO.setFHomePage( bean.getFHomePage() );
tSupplierVO.setFCreditLimit( bean.getFCreditLimit() );
tSupplierVO.setFTaxId( bean.getFTaxId() );
tSupplierVO.setFBank( bean.getFBank() );
tSupplierVO.setFAccount( bean.getFAccount() );
tSupplierVO.setFBrNo( bean.getFBrNo() );
tSupplierVO.setFBoundAttr( bean.getFBoundAttr() );
tSupplierVO.setFErpClsId( bean.getFErpClsId() );
tSupplierVO.setFShortName( bean.getFShortName() );
tSupplierVO.setFPriorityId( bean.getFPriorityId() );
tSupplierVO.setFPGroupId( bean.getFPGroupId() );
tSupplierVO.setFStatus( bean.getFStatus() );
tSupplierVO.setFLanguageId( bean.getFLanguageId() );
tSupplierVO.setFRegionId( bean.getFRegionId() );
tSupplierVO.setFTrade( bean.getFTrade() );
tSupplierVO.setFMinPoValue( bean.getFMinPoValue() );
tSupplierVO.setFMaxDebitDate( bean.getFMaxDebitDate() );
tSupplierVO.setFLegalPerson( bean.getFLegalPerson() );
tSupplierVO.setFContact( bean.getFContact() );
tSupplierVO.setFContactAcct( bean.getFContactAcct() );
tSupplierVO.setFPhoneAcct( bean.getFPhoneAcct() );
tSupplierVO.setFFaxAcct( bean.getFFaxAcct() );
tSupplierVO.setFZipAcct( bean.getFZipAcct() );
tSupplierVO.setFEmailAcct( bean.getFEmailAcct() );
tSupplierVO.setFAddrAcct( bean.getFAddrAcct() );
tSupplierVO.setFTax( bean.getFTax() );
tSupplierVO.setFCyId( bean.getFCyId() );
tSupplierVO.setFSetId( bean.getFSetId() );
tSupplierVO.setFSetDLineId( bean.getFSetDLineId() );
tSupplierVO.setFTaxNum( bean.getFTaxNum() );
tSupplierVO.setFPriceClsId( bean.getFPriceClsId() );
tSupplierVO.setFOperId( bean.getFOperId() );
tSupplierVO.setFCiqNumber( bean.getFCiqNumber() );
tSupplierVO.setFDeleted( bean.getFDeleted() );
tSupplierVO.setFSaleMode( bean.getFSaleMode() );
tSupplierVO.setFName( bean.getFName() );
tSupplierVO.setFNumber( bean.getFNumber() );
tSupplierVO.setFParentId( bean.getFParentId() );
tSupplierVO.setFShortNumber( bean.getFShortNumber() );
tSupplierVO.setFArAccountId( bean.getFArAccountId() );
tSupplierVO.setFApAccountId( bean.getFApAccountId() );
tSupplierVO.setFPreAcctId( bean.getFPreAcctId() );
tSupplierVO.setFLastTradeAmount( bean.getFLastTradeAmount() );
tSupplierVO.setFLastRPAmount( bean.getFLastRPAmount() );
tSupplierVO.setFFavorPolicy( bean.getFFavorPolicy() );
tSupplierVO.setFDepartment( bean.getFDepartment() );
tSupplierVO.setFEmployee( bean.getFEmployee() );
tSupplierVO.setFCorperate( bean.getFCorperate() );
tSupplierVO.setFBeginTradeDate( bean.getFBeginTradeDate() );
tSupplierVO.setFEndTradeDate( bean.getFEndTradeDate() );
tSupplierVO.setFLastTradeDate( bean.getFLastTradeDate() );
tSupplierVO.setFLastReceiveDate( bean.getFLastReceiveDate() );
tSupplierVO.setFCashDiscount( bean.getFCashDiscount() );
tSupplierVO.setFCurrencyId( bean.getFCurrencyId() );
tSupplierVO.setFMaxDealAmount( bean.getFMaxDealAmount() );
tSupplierVO.setFMinForeReceiveRate( bean.getFMinForeReceiveRate() );
tSupplierVO.setFMinReserveRate( bean.getFMinReserveRate() );
tSupplierVO.setFMaxForePayAmount( bean.getFMaxForePayAmount() );
tSupplierVO.setFMaxForePayRate( bean.getFMaxForePayRate() );
tSupplierVO.setFDebtLevel( bean.getFDebtLevel() );
tSupplierVO.setFCreditDays( bean.getFCreditDays() );
tSupplierVO.setFValueAddRate( bean.getFValueAddRate() );
tSupplierVO.setFPayTaxAcctId( bean.getFPayTaxAcctId() );
tSupplierVO.setFDiscount( bean.getFDiscount() );
tSupplierVO.setFTypeId( bean.getFTypeId() );
tSupplierVO.setFCreditAmount( bean.getFCreditAmount() );
tSupplierVO.setFCreditLevel( bean.getFCreditLevel() );
tSupplierVO.setFStockIdAssignee( bean.getFStockIdAssignee() );
tSupplierVO.setFBr( bean.getFBr() );
tSupplierVO.setFRegmark( bean.getFRegmark() );
tSupplierVO.setFLicAndPermit( bean.getFLicAndPermit() );
tSupplierVO.setFLicence( bean.getFLicence() );
tSupplierVO.setFPaperPeriod( bean.getFPaperPeriod() );
tSupplierVO.setFAlarmPeriod( bean.getFAlarmPeriod() );
tSupplierVO.setFOtherArAcctId( bean.getFOtherArAcctId() );
tSupplierVO.setFOtherApAcctId( bean.getFOtherApAcctId() );
tSupplierVO.setFPreArAcctId( bean.getFPreArAcctId() );
tSupplierVO.setFHelpCode( bean.getFHelpCode() );
tSupplierVO.setFModifyTime( bean.getFModifyTime() );
tSupplierVO.setFCreditDegree( bean.getFCreditDegree() );
tSupplierVO.setFRightUserId( bean.getFRightUserId() );
tSupplierVO.setFPaymentTime( bean.getFPaymentTime() );
tSupplierVO.setFSMSPhoneNumber( bean.getFSMSPhoneNumber() );
tSupplierVO.setFFullName( bean.getFFullName() );
return tSupplierVO;
}
@Override
public TSupplier convert(TSupplierVO vo) {
if ( vo == null ) {
return null;
}
TSupplier tSupplier = new TSupplier();
tSupplier.setFItemId( vo.getFItemId() );
tSupplier.setFAddress( vo.getFAddress() );
tSupplier.setFCity( vo.getFCity() );
tSupplier.setFProvince( vo.getFProvince() );
tSupplier.setFCountry( vo.getFCountry() );
tSupplier.setFPostalCode( vo.getFPostalCode() );
tSupplier.setFPhone( vo.getFPhone() );
tSupplier.setFFax( vo.getFFax() );
tSupplier.setFEmail( vo.getFEmail() );
tSupplier.setFHomePage( vo.getFHomePage() );
tSupplier.setFCreditLimit( vo.getFCreditLimit() );
tSupplier.setFTaxId( vo.getFTaxId() );
tSupplier.setFBank( vo.getFBank() );
tSupplier.setFAccount( vo.getFAccount() );
tSupplier.setFBrNo( vo.getFBrNo() );
tSupplier.setFBoundAttr( vo.getFBoundAttr() );
tSupplier.setFErpClsId( vo.getFErpClsId() );
tSupplier.setFShortName( vo.getFShortName() );
tSupplier.setFPriorityId( vo.getFPriorityId() );
tSupplier.setFPGroupId( vo.getFPGroupId() );
tSupplier.setFStatus( vo.getFStatus() );
tSupplier.setFLanguageId( vo.getFLanguageId() );
tSupplier.setFRegionId( vo.getFRegionId() );
tSupplier.setFTrade( vo.getFTrade() );
tSupplier.setFMinPoValue( vo.getFMinPoValue() );
tSupplier.setFMaxDebitDate( vo.getFMaxDebitDate() );
tSupplier.setFLegalPerson( vo.getFLegalPerson() );
tSupplier.setFContact( vo.getFContact() );
tSupplier.setFContactAcct( vo.getFContactAcct() );
tSupplier.setFPhoneAcct( vo.getFPhoneAcct() );
tSupplier.setFFaxAcct( vo.getFFaxAcct() );
tSupplier.setFZipAcct( vo.getFZipAcct() );
tSupplier.setFEmailAcct( vo.getFEmailAcct() );
tSupplier.setFAddrAcct( vo.getFAddrAcct() );
tSupplier.setFTax( vo.getFTax() );
tSupplier.setFCyId( vo.getFCyId() );
tSupplier.setFSetId( vo.getFSetId() );
tSupplier.setFSetDLineId( vo.getFSetDLineId() );
tSupplier.setFTaxNum( vo.getFTaxNum() );
tSupplier.setFPriceClsId( vo.getFPriceClsId() );
tSupplier.setFOperId( vo.getFOperId() );
tSupplier.setFCiqNumber( vo.getFCiqNumber() );
tSupplier.setFDeleted( vo.getFDeleted() );
tSupplier.setFSaleMode( vo.getFSaleMode() );
tSupplier.setFName( vo.getFName() );
tSupplier.setFNumber( vo.getFNumber() );
tSupplier.setFParentId( vo.getFParentId() );
tSupplier.setFShortNumber( vo.getFShortNumber() );
tSupplier.setFArAccountId( vo.getFArAccountId() );
tSupplier.setFApAccountId( vo.getFApAccountId() );
tSupplier.setFPreAcctId( vo.getFPreAcctId() );
tSupplier.setFLastTradeAmount( vo.getFLastTradeAmount() );
tSupplier.setFLastRPAmount( vo.getFLastRPAmount() );
tSupplier.setFFavorPolicy( vo.getFFavorPolicy() );
tSupplier.setFDepartment( vo.getFDepartment() );
tSupplier.setFEmployee( vo.getFEmployee() );
tSupplier.setFCorperate( vo.getFCorperate() );
tSupplier.setFBeginTradeDate( vo.getFBeginTradeDate() );
tSupplier.setFEndTradeDate( vo.getFEndTradeDate() );
tSupplier.setFLastTradeDate( vo.getFLastTradeDate() );
tSupplier.setFLastReceiveDate( vo.getFLastReceiveDate() );
tSupplier.setFCashDiscount( vo.getFCashDiscount() );
tSupplier.setFCurrencyId( vo.getFCurrencyId() );
tSupplier.setFMaxDealAmount( vo.getFMaxDealAmount() );
tSupplier.setFMinForeReceiveRate( vo.getFMinForeReceiveRate() );
tSupplier.setFMinReserveRate( vo.getFMinReserveRate() );
tSupplier.setFMaxForePayAmount( vo.getFMaxForePayAmount() );
tSupplier.setFMaxForePayRate( vo.getFMaxForePayRate() );
tSupplier.setFDebtLevel( vo.getFDebtLevel() );
tSupplier.setFCreditDays( vo.getFCreditDays() );
tSupplier.setFValueAddRate( vo.getFValueAddRate() );
tSupplier.setFPayTaxAcctId( vo.getFPayTaxAcctId() );
tSupplier.setFDiscount( vo.getFDiscount() );
tSupplier.setFTypeId( vo.getFTypeId() );
tSupplier.setFCreditAmount( vo.getFCreditAmount() );
tSupplier.setFCreditLevel( vo.getFCreditLevel() );
tSupplier.setFStockIdAssignee( vo.getFStockIdAssignee() );
tSupplier.setFBr( vo.getFBr() );
tSupplier.setFRegmark( vo.getFRegmark() );
tSupplier.setFLicAndPermit( vo.getFLicAndPermit() );
tSupplier.setFLicence( vo.getFLicence() );
tSupplier.setFPaperPeriod( vo.getFPaperPeriod() );
tSupplier.setFAlarmPeriod( vo.getFAlarmPeriod() );
tSupplier.setFOtherArAcctId( vo.getFOtherArAcctId() );
tSupplier.setFOtherApAcctId( vo.getFOtherApAcctId() );
tSupplier.setFPreArAcctId( vo.getFPreArAcctId() );
tSupplier.setFHelpCode( vo.getFHelpCode() );
tSupplier.setFModifyTime( vo.getFModifyTime() );
tSupplier.setFCreditDegree( vo.getFCreditDegree() );
tSupplier.setFRightUserId( vo.getFRightUserId() );
tSupplier.setFPaymentTime( vo.getFPaymentTime() );
tSupplier.setFSMSPhoneNumber( vo.getFSMSPhoneNumber() );
tSupplier.setFFullName( vo.getFFullName() );
return tSupplier;
}
}

@ -0,0 +1,31 @@
package com.lyr.gather.local.convert;
import com.lyr.gather.local.domain.model.ConfigTask;
import com.lyr.gather.local.domain.vo.ConfigTaskPageVO;
import javax.annotation.Generated;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-11-07T18:23:20+0800",
comments = "version: 1.6.2, compiler: javac, environment: Java 1.8.0_392 (Amazon.com Inc.)"
)
public class ConfigTaskConvertImpl implements ConfigTaskConvert {
@Override
public ConfigTaskPageVO convertVO(ConfigTask configTask) {
if ( configTask == null ) {
return null;
}
ConfigTaskPageVO configTaskPageVO = new ConfigTaskPageVO();
configTaskPageVO.setId( configTask.getId() );
configTaskPageVO.setTableName( configTask.getTableName() );
configTaskPageVO.setTableDescription( configTask.getTableDescription() );
configTaskPageVO.setTableNote( configTask.getTableNote() );
configTaskPageVO.setEnable( configTask.getEnable() );
configTaskPageVO.setCron( configTask.getCron() );
return configTaskPageVO;
}
}

@ -0,0 +1,51 @@
package com.lyr.gather.local.convert;
import com.alibaba.druid.pool.DruidDataSource;
import com.lyr.gather.local.domain.DataSourceConfigDTO;
import com.lyr.gather.local.domain.model.DataSourceConfig;
import com.lyr.gather.local.domain.vo.DataSourceConfigNavVO;
import javax.annotation.Generated;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-11-07T18:23:21+0800",
comments = "version: 1.6.2, compiler: javac, environment: Java 1.8.0_392 (Amazon.com Inc.)"
)
public class DataSourceConfigConvertImpl implements DataSourceConfigConvert {
@Override
public DruidDataSource convert(DataSourceConfigDTO bean) {
if ( bean == null ) {
return null;
}
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setName( bean.getName() );
druidDataSource.setUsername( bean.getUsername() );
druidDataSource.setPassword( bean.getPassword() );
return druidDataSource;
}
@Override
public DataSourceConfigNavVO convertVO(DataSourceConfig bean) {
if ( bean == null ) {
return null;
}
DataSourceConfigNavVO dataSourceConfigNavVO = new DataSourceConfigNavVO();
dataSourceConfigNavVO.setId( bean.getId() );
dataSourceConfigNavVO.setAlias( bean.getAlias() );
dataSourceConfigNavVO.setName( bean.getName() );
dataSourceConfigNavVO.setDbType( bean.getDbType() );
dataSourceConfigNavVO.setUrl( bean.getUrl() );
dataSourceConfigNavVO.setUsername( bean.getUsername() );
dataSourceConfigNavVO.setPassword( bean.getPassword() );
dataSourceConfigNavVO.setDriverClassName( bean.getDriverClassName() );
dataSourceConfigNavVO.setIsEnabled( bean.getIsEnabled() );
return dataSourceConfigNavVO;
}
}

@ -49,7 +49,7 @@ public class GenController extends BaseController {
@PreAuthorize("@ss.hasPermi('tool:gen:list')") @PreAuthorize("@ss.hasPermi('tool:gen:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo genList(GenTable genTable) { public TableDataInfo genList(GenTable genTable) {
startPage();
List<GenTable> list = genTableService.selectGenTableList(genTable); List<GenTable> list = genTableService.selectGenTableList(genTable);
return getDataTable(list); return getDataTable(list);
} }
@ -76,7 +76,7 @@ public class GenController extends BaseController {
@PreAuthorize("@ss.hasPermi('tool:gen:list')") @PreAuthorize("@ss.hasPermi('tool:gen:list')")
@GetMapping("/db/list") @GetMapping("/db/list")
public TableDataInfo dataList(GenTable genTable) { public TableDataInfo dataList(GenTable genTable) {
startPage();
List<GenTable> list = genTableService.selectDbTableList(genTable); List<GenTable> list = genTableService.selectDbTableList(genTable);
return getDataTable(list); return getDataTable(list);
} }

@ -44,7 +44,7 @@ public class ${ClassName}Controller extends BaseController {
@GetMapping("/list") @GetMapping("/list")
#if($table.crud || $table.sub) #if($table.crud || $table.sub)
public TableDataInfo list(${ClassName} ${className}) { public TableDataInfo list(${ClassName} ${className}) {
startPage();
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return getDataTable(list); return getDataTable(list);
} }

@ -38,7 +38,7 @@ public class SysJobController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:job:list')") @PreAuthorize("@ss.hasPermi('monitor:job:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysJob sysJob) { public TableDataInfo list(SysJob sysJob) {
startPage();
List<SysJob> list = jobService.selectJobList(sysJob); List<SysJob> list = jobService.selectJobList(sysJob);
return getDataTable(list); return getDataTable(list);
} }

@ -32,7 +32,7 @@ public class SysJobLogController extends BaseController {
@PreAuthorize("@ss.hasPermi('monitor:job:list')") @PreAuthorize("@ss.hasPermi('monitor:job:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysJobLog sysJobLog) { public TableDataInfo list(SysJobLog sysJobLog) {
startPage();
List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog); List<SysJobLog> list = jobLogService.selectJobLogList(sysJobLog);
return getDataTable(list); return getDataTable(list);
} }

@ -23,6 +23,16 @@
<artifactId>sync-common</artifactId> <artifactId>sync-common</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>

@ -1,5 +1,6 @@
package com.lyr.system.domain; package com.lyr.system.domain;
import com.lyr.common.utils.StringUtils; import com.lyr.common.utils.StringUtils;
/** /**

@ -1,5 +1,6 @@
package com.lyr.system.mapper; package com.lyr.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lyr.common.core.domain.entity.SysDept; import com.lyr.common.core.domain.entity.SysDept;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -10,7 +11,7 @@ import java.util.List;
* *
* @author ruoyi * @author ruoyi
*/ */
public interface SysDeptMapper { public interface SysDeptMapper extends BaseMapper<SysDept> {
/** /**
* *
* *

@ -64,6 +64,14 @@ public interface ISysConfigService {
*/ */
void deleteConfigByIds(Long[] configIds); void deleteConfigByIds(Long[] configIds);
/**
*
*
* @return
*/
String getConfigCache(String configKey);
/** /**
* *
*/ */

@ -152,6 +152,7 @@ public class SysConfigServiceImpl implements ISysConfigService {
} }
} }
/** /**
* *
*/ */
@ -163,6 +164,13 @@ public class SysConfigServiceImpl implements ISysConfigService {
} }
} }
@Override
public String getConfigCache(String configKey) {
Object value = redisCache.getCacheObject(getCacheKey(configKey));
return value != null ? value.toString() : null;
}
/** /**
* *
*/ */

@ -2,6 +2,7 @@ package com.lyr.system.service.impl;
import com.lyr.common.core.domain.entity.SysDictData; import com.lyr.common.core.domain.entity.SysDictData;
import com.lyr.common.utils.DictUtils; import com.lyr.common.utils.DictUtils;
import com.lyr.common.utils.spring.SpringUtils;
import com.lyr.system.mapper.SysDictDataMapper; import com.lyr.system.mapper.SysDictDataMapper;
import com.lyr.system.service.ISysDictDataService; import com.lyr.system.service.ISysDictDataService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;

@ -23,8 +23,18 @@
</resultMap> </resultMap>
<sql id="selectDeptVo"> <sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, select d.dept_id,
d.del_flag, d.create_by, d.create_time d.parent_id,
d.ancestors,
d.dept_name,
d.order_num,
d.leader,
d.phone,
d.email,
d.status,
d.del_flag,
d.create_by,
d.create_time
from sys_dept d from sys_dept d
</sql> </sql>
@ -61,27 +71,47 @@
</select> </select>
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult"> <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, select d.dept_id,
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name d.parent_id,
d.ancestors,
d.dept_name,
d.order_num,
d.leader,
d.phone,
d.email,
d.status,
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
from sys_dept d from sys_dept d
where d.dept_id = #{deptId} where d.dept_id = #{deptId}
</select> </select>
<select id="checkDeptExistUser" parameterType="Long" resultType="int"> <select id="checkDeptExistUser" parameterType="Long" resultType="int">
select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0' select count(1)
from sys_user
where dept_id = #{deptId}
and del_flag = '0'
</select> </select>
<select id="hasChildByDeptId" parameterType="Long" resultType="int"> <select id="hasChildByDeptId" parameterType="Long" resultType="int">
select count(1) from sys_dept select count(1)
where del_flag = '0' and parent_id = #{deptId} limit 1 from sys_dept
where del_flag = '0'
and parent_id = #{deptId}
limit 1
</select> </select>
<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult"> <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
select * from sys_dept where find_in_set(#{deptId}, ancestors) select *
from sys_dept
where find_in_set(#{deptId}, ancestors)
</select> </select>
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int"> <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors) select count(*)
from sys_dept
where status = 0
and del_flag = '0'
and find_in_set(#{deptId}, ancestors)
</select> </select>
<select id="checkDeptNameUnique" resultMap="SysDeptResult"> <select id="checkDeptNameUnique" resultMap="SysDeptResult">
@ -155,7 +185,9 @@
</update> </update>
<delete id="deleteDeptById" parameterType="Long"> <delete id="deleteDeptById" parameterType="Long">
update sys_dept set del_flag = '2' where dept_id = #{deptId} update sys_dept
set del_flag = '2'
where dept_id = #{deptId}
</delete> </delete>
</mapper> </mapper>
Loading…
Cancel
Save