Compare commits
No commits in common. "dev.saas.customer" and "master" have entirely different histories.
dev.saas.c
...
master
|
@ -16,10 +16,23 @@
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- <dependency>-->
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
<!-- <groupId>com.muyu</groupId>-->
|
<dependency>
|
||||||
<!-- <artifactId>cloud-common-saas</artifactId>-->
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
<!-- </dependency>-->
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Sentinel -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- SpringBoot Web -->
|
<!-- SpringBoot Web -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -45,48 +58,6 @@
|
||||||
<artifactId>cloud-common-api-doc</artifactId>
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Nacos -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Nacos Config -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- SpringCloud Alibaba Sentinel -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Mysql Connector -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MuYu Common DataSource -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-datasource</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MuYu Common DataScope -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-datascope</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- MuYu Common Log -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-log</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package com.muyu.auth;
|
package com.muyu.auth;
|
||||||
|
|
||||||
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
|
|
||||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
|
||||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
|
||||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
@ -13,18 +10,10 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
@EnableCustomConfig
|
|
||||||
@EnableMyFeignClients
|
@EnableMyFeignClients
|
||||||
@SpringBootApplication(
|
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
|
||||||
exclude = {
|
|
||||||
DataSourceAutoConfiguration.class,
|
|
||||||
DruidDataSourceAutoConfigure.class,
|
|
||||||
DynamicDataSourceAutoConfiguration.class
|
|
||||||
}
|
|
||||||
)
|
|
||||||
public class CloudAuthApplication {
|
public class CloudAuthApplication {
|
||||||
public static void main (String[] args) {
|
public static void main (String[] args) {
|
||||||
SpringApplication.run(CloudAuthApplication.class, args);
|
SpringApplication.run(CloudAuthApplication.class, args);
|
||||||
System.out.println("CloudAuth 模块启动成功!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import com.muyu.common.security.auth.AuthUtil;
|
||||||
import com.muyu.common.security.service.TokenService;
|
import com.muyu.common.security.service.TokenService;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
@ -25,16 +25,16 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
public class TokenController {
|
public class TokenController {
|
||||||
@Resource
|
@Autowired
|
||||||
private TokenService tokenService;
|
private TokenService tokenService;
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private SysLoginService sysLoginService;
|
private SysLoginService sysLoginService;
|
||||||
|
|
||||||
@PostMapping("login")
|
@PostMapping("login")
|
||||||
public Result<?> login (@RequestBody LoginBody form) {
|
public Result<?> login (@RequestBody LoginBody form) {
|
||||||
// 用户登录
|
// 用户登录
|
||||||
LoginUser userInfo = sysLoginService.login(form);
|
LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
|
||||||
// 获取登录token
|
// 获取登录token
|
||||||
return Result.success(tokenService.createToken(userInfo));
|
return Result.success(tokenService.createToken(userInfo));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
package com.muyu.auth.form;
|
package com.muyu.auth.form;
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户登录对象
|
* 用户登录对象
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
@Data
|
|
||||||
public class LoginBody {
|
public class LoginBody {
|
||||||
|
|
||||||
private String firmCode;
|
|
||||||
/**
|
/**
|
||||||
* 用户名
|
* 用户名
|
||||||
*/
|
*/
|
||||||
|
@ -20,4 +15,20 @@ public class LoginBody {
|
||||||
* 用户密码
|
* 用户密码
|
||||||
*/
|
*/
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
|
public String getUsername () {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername (String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword () {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword (String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.muyu.auth.service;
|
package com.muyu.auth.service;
|
||||||
|
|
||||||
import com.muyu.auth.form.LoginBody;
|
|
||||||
import com.muyu.common.core.constant.CacheConstants;
|
import com.muyu.common.core.constant.CacheConstants;
|
||||||
import com.muyu.common.core.constant.Constants;
|
import com.muyu.common.core.constant.Constants;
|
||||||
import com.muyu.common.core.constant.SecurityConstants;
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
|
@ -13,16 +12,12 @@ import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.core.utils.ip.IpUtils;
|
import com.muyu.common.core.utils.ip.IpUtils;
|
||||||
import com.muyu.common.redis.service.RedisService;
|
import com.muyu.common.redis.service.RedisService;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.remote.RemoteSaasService;
|
|
||||||
import com.muyu.common.system.remote.RemoteUserService;
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录校验方法
|
* 登录校验方法
|
||||||
*
|
*
|
||||||
|
@ -30,30 +25,24 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class SysLoginService {
|
public class SysLoginService {
|
||||||
@Resource
|
@Autowired
|
||||||
private RemoteUserService remoteUserService;
|
private RemoteUserService remoteUserService;
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private SysPasswordService passwordService;
|
private SysPasswordService passwordService;
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private SysRecordLogService recordLogService;
|
private SysRecordLogService recordLogService;
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private RemoteSaasService remoteSaasService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
*/
|
*/
|
||||||
public LoginUser login (LoginBody form) {
|
public LoginUser login (String username, String password) {
|
||||||
String firmCode = form.getFirmCode();
|
|
||||||
String username = form.getUsername();
|
|
||||||
String password = form.getPassword();
|
|
||||||
// 用户名或密码为空 错误
|
// 用户名或密码为空 错误
|
||||||
if (StringUtils.isAnyBlank(firmCode, username, password)) {
|
if (StringUtils.isAnyBlank(username, password)) {
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
|
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
|
||||||
throw new ServiceException("用户/密码必须填写");
|
throw new ServiceException("用户/密码必须填写");
|
||||||
}
|
}
|
||||||
|
@ -76,7 +65,8 @@ public class SysLoginService {
|
||||||
throw new ServiceException("很遗憾,访问IP已被列入系统黑名单");
|
throw new ServiceException("很遗憾,访问IP已被列入系统黑名单");
|
||||||
}
|
}
|
||||||
// 查询用户信息
|
// 查询用户信息
|
||||||
Result<LoginUser> userResult = remoteUserService.getUserInfo(firmCode, username, SecurityConstants.INNER);
|
Result<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
||||||
|
|
||||||
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
|
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
||||||
throw new ServiceException("登录用户:" + username + " 不存在");
|
throw new ServiceException("登录用户:" + username + " 不存在");
|
||||||
|
@ -86,8 +76,8 @@ public class SysLoginService {
|
||||||
throw new ServiceException(userResult.getMsg());
|
throw new ServiceException(userResult.getMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginUser loginUser = userResult.getData();
|
LoginUser userInfo = userResult.getData();
|
||||||
SysUser user = loginUser.getSysUser();
|
SysUser user = userResult.getData().getSysUser();
|
||||||
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
|
if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) {
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除");
|
||||||
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
throw new ServiceException("对不起,您的账号:" + username + " 已被删除");
|
||||||
|
@ -98,8 +88,7 @@ public class SysLoginService {
|
||||||
}
|
}
|
||||||
passwordService.validate(user, password);
|
passwordService.validate(user, password);
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
|
||||||
|
return userInfo;
|
||||||
return loginUser;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logout (String loginName) {
|
public void logout (String loginName) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.muyu.common.core.exception.ServiceException;
|
||||||
import com.muyu.common.redis.service.RedisService;
|
import com.muyu.common.redis.service.RedisService;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.domain.SysUser;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -18,14 +18,14 @@ import java.util.concurrent.TimeUnit;
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class SysPasswordService {
|
public class SysPasswordService {
|
||||||
@Resource
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
private int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT;
|
private int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT;
|
||||||
|
|
||||||
private Long lockTime = CacheConstants.PASSWORD_LOCK_TIME;
|
private Long lockTime = CacheConstants.PASSWORD_LOCK_TIME;
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private SysRecordLogService recordLogService;
|
private SysRecordLogService recordLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.core.utils.ip.IpUtils;
|
import com.muyu.common.core.utils.ip.IpUtils;
|
||||||
import com.muyu.common.system.remote.RemoteLogService;
|
import com.muyu.common.system.remote.RemoteLogService;
|
||||||
import com.muyu.common.system.domain.SysLogininfor;
|
import com.muyu.common.system.domain.SysLogininfor;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,7 +16,7 @@ import org.springframework.stereotype.Component;
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class SysRecordLogService {
|
public class SysRecordLogService {
|
||||||
@Resource
|
@Autowired
|
||||||
private RemoteLogService remoteLogService;
|
private RemoteLogService remoteLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,10 +4,10 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 110.42.213.184:8848
|
addr: nacos.muyu.icu:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: icecream
|
namespace: muyu-cloud
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
|
@ -22,26 +22,26 @@ spring:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: ${nacos.addr}
|
server-addr: ${nacos.addr}
|
||||||
# nacos用户名
|
# nacos用户名
|
||||||
# username: ${nacos.user-name}
|
username: ${nacos.user-name}
|
||||||
# # nacos密码
|
# nacos密码
|
||||||
# password: ${nacos.password}
|
password: ${nacos.password}
|
||||||
# 命名空间
|
# 命名空间
|
||||||
namespace: ${nacos.namespace}
|
namespace: ${nacos.namespace}
|
||||||
config:
|
config:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: ${nacos.addr}
|
server-addr: ${nacos.addr}
|
||||||
# nacos用户名
|
# nacos用户名
|
||||||
# username: ${nacos.user-name}
|
username: ${nacos.user-name}
|
||||||
# # nacos密码
|
# nacos密码
|
||||||
# password: ${nacos.password}
|
password: ${nacos.password}
|
||||||
# 命名空间
|
# 命名空间
|
||||||
namespace: ${nacos.namespace}
|
namespace: ${nacos.namespace}
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
# 系统环境Config共享配置
|
|
||||||
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
# 系统共享配置
|
# 系统共享配置
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# 系统环境Config共享配置
|
||||||
|
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,7 @@
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.yulichang</groupId>
|
|
||||||
<artifactId>mybatis-plus-join-boot-starter</artifactId>
|
|
||||||
<version>1.4.11</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- SpringCloud Openfeign -->
|
<!-- SpringCloud Openfeign -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
|
|
@ -45,9 +45,4 @@ public class SecurityConstants {
|
||||||
* 角色权限
|
* 角色权限
|
||||||
*/
|
*/
|
||||||
public static final String ROLE_PERMISSION = "role_permission";
|
public static final String ROLE_PERMISSION = "role_permission";
|
||||||
|
|
||||||
/**
|
|
||||||
* SAAS请求头的key
|
|
||||||
*/
|
|
||||||
public static final String SAAS_KEY = "ent-code";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,4 @@ public class ServiceNameConstants {
|
||||||
* 文件服务的serviceid
|
* 文件服务的serviceid
|
||||||
*/
|
*/
|
||||||
public static final String FILE_SERVICE = "cloud-file";
|
public static final String FILE_SERVICE = "cloud-file";
|
||||||
|
|
||||||
/**
|
|
||||||
* 智能车联服务
|
|
||||||
*/
|
|
||||||
public static final String SMART_SERVICE = "cloud-smart-car";
|
|
||||||
|
|
||||||
public static final String ENT_SERVICE = "cloud-ent";
|
|
||||||
|
|
||||||
public static final String SAAS_SERVICE = "cloud-system-saas";
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,12 +80,4 @@ public class SecurityContextHolder {
|
||||||
public static void remove () {
|
public static void remove () {
|
||||||
THREAD_LOCAL.remove();
|
THREAD_LOCAL.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSaasKey() {
|
|
||||||
return get(SecurityConstants.SAAS_KEY);
|
|
||||||
}
|
|
||||||
public static void setSaasKey(String saasKey) {
|
|
||||||
set(SecurityConstants.SAAS_KEY,saasKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ package com.muyu.common.core.exception;
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
public class ServiceException extends RuntimeException {
|
public final class ServiceException extends RuntimeException {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,7 @@ public class ServiceException extends RuntimeException {
|
||||||
/**
|
/**
|
||||||
* 错误明细,内部调试错误
|
* 错误明细,内部调试错误
|
||||||
* <p>
|
* <p>
|
||||||
* 和 {CommonResult#getDetailMessage()} 一致的设计
|
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
|
||||||
*/
|
*/
|
||||||
private String detailMessage;
|
private String detailMessage;
|
||||||
|
|
||||||
|
|
|
@ -162,15 +162,4 @@ public class JwtUtils {
|
||||||
public static String getValue (Claims claims, String key) {
|
public static String getValue (Claims claims, String key) {
|
||||||
return Convert.toStr(claims.get(key), "");
|
return Convert.toStr(claims.get(key), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据身份信息获取SAASKey
|
|
||||||
*
|
|
||||||
* @param claims 身份信息
|
|
||||||
*
|
|
||||||
* @return saas_key
|
|
||||||
*/
|
|
||||||
public static String getSaasKey(Claims claims) {
|
|
||||||
return getValue(claims, SecurityConstants.SAAS_KEY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.aspectj.lang.annotation.Aspect;
|
||||||
import org.aspectj.lang.annotation.Before;
|
import org.aspectj.lang.annotation.Before;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.NamedThreadLocal;
|
import org.springframework.core.NamedThreadLocal;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -48,7 +48,7 @@ public class LogAspect {
|
||||||
*/
|
*/
|
||||||
private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<Long>("Cost Time");
|
private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<Long>("Cost Time");
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private AsyncLogService asyncLogService;
|
private AsyncLogService asyncLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.muyu.common.log.service;
|
||||||
import com.muyu.common.core.constant.SecurityConstants;
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
import com.muyu.common.system.remote.RemoteLogService;
|
import com.muyu.common.system.remote.RemoteLogService;
|
||||||
import com.muyu.common.system.domain.SysOperLog;
|
import com.muyu.common.system.domain.SysOperLog;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ import org.springframework.stereotype.Service;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class AsyncLogService {
|
public class AsyncLogService {
|
||||||
@Resource
|
@Autowired
|
||||||
private RemoteLogService remoteLogService;
|
private RemoteLogService remoteLogService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.muyu.common.rabbit;
|
||||||
|
|
||||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||||
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar;
|
import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar;
|
||||||
import javax.annotation.Resource;
|
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.messaging.converter.MappingJackson2MessageConverter;
|
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
|
||||||
|
@ -16,7 +16,7 @@ public class RabbitListenerConfigurer implements org.springframework.amqp.rabbit
|
||||||
}
|
}
|
||||||
|
|
||||||
//以下配置RabbitMQ消息服务
|
//以下配置RabbitMQ消息服务
|
||||||
@Resource
|
@Autowired
|
||||||
public ConnectionFactory connectionFactory;
|
public ConnectionFactory connectionFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.muyu.common.redis.service;
|
package com.muyu.common.redis.service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
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;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
@ -18,7 +18,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
||||||
@Component
|
@Component
|
||||||
public class RedisService {
|
public class RedisService {
|
||||||
@Resource
|
@Autowired
|
||||||
public RedisTemplate redisTemplate;
|
public RedisTemplate redisTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>cloud-common-saas</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- 多数据源依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-datasource</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 鉴权依赖 -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-security</artifactId>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</project>
|
|
|
@ -1,105 +0,0 @@
|
||||||
package com.muyu.cloud.common.many.datasource;
|
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
|
||||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
|
||||||
import com.muyu.cloud.common.saas.domain.model.EntInfo;
|
|
||||||
import com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory;
|
|
||||||
import com.muyu.cloud.common.many.datasource.domain.model.DataSourceInfo;
|
|
||||||
import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
|
|
||||||
import com.muyu.cloud.common.saas.exception.SaaSException;
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.common.core.utils.SpringUtils;
|
|
||||||
import com.muyu.common.system.domain.SysEnt;
|
|
||||||
import com.muyu.common.system.remote.RemoteUserService;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
|
|
||||||
import org.springframework.boot.ApplicationArguments;
|
|
||||||
import org.springframework.boot.ApplicationRunner;
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: DongZeLiang
|
|
||||||
* @date: 2024/6/3
|
|
||||||
* @Description: 多数据源
|
|
||||||
* @Version: 1.0
|
|
||||||
*/
|
|
||||||
@Log4j2
|
|
||||||
@AutoConfiguration(before = {MybatisPlusAutoConfiguration.class, MybatisAutoConfiguration.class})
|
|
||||||
@Component
|
|
||||||
public class ManyDataSource implements ApplicationRunner{
|
|
||||||
|
|
||||||
|
|
||||||
private List<EntInfo> dataSourceInfoList(){
|
|
||||||
RemoteUserService remoteUserService = SpringUtils.getBean(RemoteUserService.class);
|
|
||||||
Result<List<SysEnt>> listResult = remoteUserService.list(new SysEnt());
|
|
||||||
if (listResult==null){
|
|
||||||
throw new SaaSException("saas远调数据源错误");
|
|
||||||
}
|
|
||||||
List<SysEnt> data = listResult.getData();
|
|
||||||
System.out.println(data);
|
|
||||||
if (listResult.getCode() == Result.SUCCESS && data !=null){
|
|
||||||
List<EntInfo> list = new ArrayList<>();
|
|
||||||
for (SysEnt row : data) {
|
|
||||||
list.add(
|
|
||||||
EntInfo.builder()
|
|
||||||
.entCode(row.getEntCode())
|
|
||||||
.dbName(row.getDbName())
|
|
||||||
.ip(row.getIp())
|
|
||||||
.port(row.getPort())
|
|
||||||
.userName(row.getUserName())
|
|
||||||
.password(row.getPassword())
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}else {
|
|
||||||
log.error("远调数据源错误,远调数据为:{}", JSON.toJSONString(listResult));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
|
|
||||||
// 企业列表 企业CODE,端口,IP
|
|
||||||
Map<Object, Object> dataSourceMap = new HashMap<>();
|
|
||||||
Objects.requireNonNull(dataSourceInfoList())
|
|
||||||
.stream()
|
|
||||||
.map(DataSourceInfo::hostAndPortBuild)
|
|
||||||
.forEach(dataSourceInfo -> {
|
|
||||||
dataSourceMap.put(dataSourceInfo.getKey(), druidDataSourceFactory.create(dataSourceInfo));
|
|
||||||
});
|
|
||||||
//设置动态数据源
|
|
||||||
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
|
||||||
// dynamicDataSource.setDefaultTargetDataSource(masterDataSource());
|
|
||||||
dynamicDataSource.setTargetDataSources(dataSourceMap);
|
|
||||||
//将数据源信息备份在defineTargetDataSources中
|
|
||||||
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
|
|
||||||
log.info("动态数据源加载完成,持有key:{}",dynamicDataSource.getKeys());
|
|
||||||
return dynamicDataSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(ApplicationArguments args) {
|
|
||||||
DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class);
|
|
||||||
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
|
|
||||||
for (EntInfo entInfo : dataSourceInfoList()) {
|
|
||||||
DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(entInfo);
|
|
||||||
DruidDataSource druidDataSource = druidDataSourceFactory.create(dataSourceInfo);
|
|
||||||
dynamicDataSource.put(dataSourceInfo.getKey(), druidDataSource);
|
|
||||||
log.info("存储数据连接池为:key:{}",dataSourceInfo.getKey());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// @Bean
|
|
||||||
// public SqlSessionFactory sqlSessionFactory(DynamicDataSource dataSource) throws Exception {
|
|
||||||
// SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
|
|
||||||
// sessionFactory.setDataSource(dataSource);
|
|
||||||
// return sessionFactory.getObject();
|
|
||||||
// }
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package com.muyu.cloud.common.many.datasource.constents;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author DongZl
|
|
||||||
* @description: 数据源常量
|
|
||||||
* @Date 2023-8-1 上午 11:02
|
|
||||||
*/
|
|
||||||
public class DatasourceContent {
|
|
||||||
|
|
||||||
public final static String DATASOURCE_URL = "jdbc:mysql://{}:{}/{}?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
|
|
||||||
|
|
||||||
public final static String USER_NAME = "root";
|
|
||||||
|
|
||||||
public final static String PASSWORD = "bawei2112A";
|
|
||||||
|
|
||||||
public final static String IP = "127.0.0.1";
|
|
||||||
|
|
||||||
public final static Integer PORT = 3306;
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
package com.muyu.cloud.common.many.datasource.domain.model;
|
|
||||||
|
|
||||||
import com.muyu.cloud.common.many.datasource.constents.DatasourceContent;
|
|
||||||
import com.muyu.cloud.common.saas.domain.model.EntInfo;
|
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author DongZl
|
|
||||||
* @description: 数据源实体类
|
|
||||||
* @Date 2023-8-1 上午 11:15
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class DataSourceInfo {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 键
|
|
||||||
*/
|
|
||||||
private String key;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 地址
|
|
||||||
*/
|
|
||||||
private String url;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户名
|
|
||||||
*/
|
|
||||||
private String userName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 密码
|
|
||||||
*/
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
|
|
||||||
// public static DataSourceInfo hostAndPortBuild(String key, String host, Integer port) {
|
|
||||||
// return DataSourceInfo.builder()
|
|
||||||
// .key(key)
|
|
||||||
// .url(StringUtils.format(DatasourceContent.DATASOURCE_URL, host, port, key))
|
|
||||||
// .password(DatasourceContent.PASSWORD)
|
|
||||||
// .userName(DatasourceContent.USER_NAME)
|
|
||||||
// .build();
|
|
||||||
// }
|
|
||||||
|
|
||||||
public static DataSourceInfo hostAndPortBuild(EntInfo entInfo) {
|
|
||||||
return DataSourceInfo.builder()
|
|
||||||
.key(entInfo.getEntCode())
|
|
||||||
.url(StringUtils.format(DatasourceContent.DATASOURCE_URL, entInfo.getIp(), entInfo.getPort(), entInfo.getDbName()))
|
|
||||||
.userName(entInfo.getUserName())
|
|
||||||
.password(entInfo.getPassword())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
package com.muyu.cloud.common.many.datasource.factory;
|
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
|
||||||
import com.muyu.cloud.common.many.datasource.domain.model.DataSourceInfo;
|
|
||||||
import lombok.extern.log4j.Log4j2;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.sql.SQLException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: DongZeLiang
|
|
||||||
* @date: 2024/6/3
|
|
||||||
* @Description: Druid工厂
|
|
||||||
* @Version: 1.0
|
|
||||||
*/
|
|
||||||
@Log4j2
|
|
||||||
@Component
|
|
||||||
public class DruidDataSourceFactory {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Description: 根据传递的数据源信息测试数据库连接
|
|
||||||
* @Author Dongzl
|
|
||||||
*/
|
|
||||||
public DruidDataSource create(DataSourceInfo dataSourceInfo) {
|
|
||||||
DruidDataSource druidDataSource = new DruidDataSource();
|
|
||||||
druidDataSource.setUrl(dataSourceInfo.getUrl());
|
|
||||||
druidDataSource.setConnectTimeout(10000);
|
|
||||||
druidDataSource.setMaxWait(60000);
|
|
||||||
druidDataSource.setUsername(dataSourceInfo.getUserName());
|
|
||||||
druidDataSource.setPassword(dataSourceInfo.getPassword());
|
|
||||||
druidDataSource.setBreakAfterAcquireFailure(true);
|
|
||||||
druidDataSource.setConnectionErrorRetryAttempts(0);
|
|
||||||
try {
|
|
||||||
druidDataSource.getConnection(2000);
|
|
||||||
log.info("{} -> 数据源连接成功", dataSourceInfo.getKey());
|
|
||||||
return druidDataSource;
|
|
||||||
} catch (SQLException throwables) {
|
|
||||||
log.error("数据源 {} 连接失败,用户名:{},密码 {}, 原因:{}",dataSourceInfo.getUrl(),dataSourceInfo.getUserName(),dataSourceInfo.getPassword(), throwables);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
package com.muyu.cloud.common.many.datasource.holder;
|
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 数据源切换处理
|
|
||||||
*
|
|
||||||
* @author Dongzl
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public class DynamicDataSourceHolder {
|
|
||||||
/**
|
|
||||||
* 保存动态数据源名称
|
|
||||||
*/
|
|
||||||
private static final ThreadLocal<String> DYNAMIC_DATASOURCE_KEY = new ThreadLocal<>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置/切换数据源,决定当前线程使用哪个数据源
|
|
||||||
*/
|
|
||||||
public static void setDynamicDataSourceKey(String key){
|
|
||||||
log.info("数据源切换为:{}",key);
|
|
||||||
DYNAMIC_DATASOURCE_KEY.set(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取动态数据源名称,默认使用mater数据源
|
|
||||||
*/
|
|
||||||
public static String getDynamicDataSourceKey(){
|
|
||||||
String key = DYNAMIC_DATASOURCE_KEY.get();
|
|
||||||
Assert.notNull(key, "请携带数据标识");
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除当前数据源
|
|
||||||
*/
|
|
||||||
public static void removeDynamicDataSourceKey(){
|
|
||||||
log.info("移除数据源:{}",DYNAMIC_DATASOURCE_KEY.get());
|
|
||||||
DYNAMIC_DATASOURCE_KEY.remove();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package com.muyu.cloud.common.many.datasource.role;
|
|
||||||
|
|
||||||
import com.alibaba.druid.pool.DruidDataSource;
|
|
||||||
import com.muyu.cloud.common.many.datasource.holder.DynamicDataSourceHolder;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 动态数据源
|
|
||||||
* 调用AddDefineDataSource组件的addDefineDynamicDataSource()方法,获取原来targetdatasources的map,并将新的数据源信息添加到map中,并替换targetdatasources中的map
|
|
||||||
* 切换数据源时可以使用@DataSource(value = "数据源名称"),或者DynamicDataSourceContextHolder.setContextKey("数据源名称")
|
|
||||||
* @author Dongzl
|
|
||||||
*/
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
@Slf4j
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class DynamicDataSource extends AbstractRoutingDataSource {
|
|
||||||
/**
|
|
||||||
* 备份所有数据源信息 备份的是个 指针 !!!
|
|
||||||
*/
|
|
||||||
private Map<Object, Object> defineTargetDataSources;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判定键是否出站了
|
|
||||||
* @param key 键
|
|
||||||
* @return 存在结果 true存在 false不存在
|
|
||||||
*/
|
|
||||||
public boolean hashKey(String key){
|
|
||||||
return defineTargetDataSources.containsKey(key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加数据库
|
|
||||||
* @param key 键
|
|
||||||
* @param value 数据源
|
|
||||||
*/
|
|
||||||
public void put(String key, DruidDataSource value) {
|
|
||||||
if (value!=null) {
|
|
||||||
defineTargetDataSources.put(key, value);
|
|
||||||
this.afterPropertiesSet();
|
|
||||||
}else{
|
|
||||||
log.warn("Key为 {} 的数据源为空!",key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 决定当前线程使用哪个数据源
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected Object determineCurrentLookupKey() {
|
|
||||||
return DynamicDataSourceHolder.getDynamicDataSourceKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Object> getKeys() {
|
|
||||||
return defineTargetDataSources.keySet().stream().toList();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
package com.muyu.cloud.common.saas.contents;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: DongZeLiang
|
|
||||||
* @date: 2024/6/3
|
|
||||||
* @Description: SAAS常量
|
|
||||||
* @Version: 1.0
|
|
||||||
*/
|
|
||||||
public class SaaSConstant {
|
|
||||||
|
|
||||||
public final static String SAAS_KEY = "ent-code";
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
package com.muyu.cloud.common.saas.domain.model;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: DongZeLiang
|
|
||||||
* @date: 2024/6/3
|
|
||||||
* @Description: 企业信息
|
|
||||||
* @Version: 1.0
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class EntInfo {
|
|
||||||
|
|
||||||
private String entCode;
|
|
||||||
|
|
||||||
private String ip;
|
|
||||||
|
|
||||||
private Integer port;
|
|
||||||
|
|
||||||
private String dbName;
|
|
||||||
|
|
||||||
private String userName;
|
|
||||||
|
|
||||||
private String password;
|
|
||||||
}
|
|
|
@ -1,28 +0,0 @@
|
||||||
package com.muyu.cloud.common.saas.exception;
|
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.common.core.exception.ServiceException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: DongZeLiang
|
|
||||||
* @date: 2024/6/3
|
|
||||||
* @Description: SaaS异常类
|
|
||||||
* @Version: 1.0
|
|
||||||
*/
|
|
||||||
public class SaaSException extends ServiceException {
|
|
||||||
|
|
||||||
public SaaSException (String message, Integer code) {
|
|
||||||
super(message, code);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SaaSException (String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 空构造方法,避免反序列化问题
|
|
||||||
*/
|
|
||||||
public SaaSException () {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
package com.muyu.cloud.common.saas.interceptor;
|
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
|
||||||
import com.muyu.cloud.common.saas.contents.SaaSConstant;
|
|
||||||
import com.muyu.cloud.common.many.datasource.holder.DynamicDataSourceHolder;
|
|
||||||
import com.muyu.cloud.common.saas.exception.SaaSException;
|
|
||||||
import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
|
|
||||||
import com.muyu.common.core.context.SecurityContextHolder;
|
|
||||||
import com.muyu.common.core.utils.ServletUtils;
|
|
||||||
import com.muyu.common.core.utils.SpringUtils;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.web.method.HandlerMethod;
|
|
||||||
import org.springframework.web.servlet.AsyncHandlerInterceptor;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: DongZeLiang
|
|
||||||
* @date: 2024/6/3
|
|
||||||
* @Description: SAAS拦截器
|
|
||||||
* @Version: 1.0
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public class SaaSInterceptor implements AsyncHandlerInterceptor {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 之前
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean preHandle (HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
||||||
if (!(handler instanceof HandlerMethod)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String saasKey = ServletUtils.getHeader(request, SaaSConstant.SAAS_KEY);
|
|
||||||
log.info("访问路径:{},携带SaaSKey:{}",request.getRequestURI(),saasKey);
|
|
||||||
if (saasKey == null) {
|
|
||||||
throw new SaaSException("SaaS非法访问");
|
|
||||||
}else {
|
|
||||||
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
|
|
||||||
if (!dynamicDataSource.hashKey(saasKey)){
|
|
||||||
throw new SaaSException("SaaS非法访问");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DynamicDataSourceHolder.setDynamicDataSourceKey(saasKey);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 之后
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void afterConcurrentHandlingStarted (HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
||||||
DynamicDataSourceHolder.removeDynamicDataSourceKey();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,31 +0,0 @@
|
||||||
package com.muyu.cloud.common.saas.interceptor;
|
|
||||||
|
|
||||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拦截器配置
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
*/
|
|
||||||
public class WebMvcSaaSConfig implements WebMvcConfigurer {
|
|
||||||
/**
|
|
||||||
* 不需要拦截的地址
|
|
||||||
*/
|
|
||||||
public static final String[] EXCLUDE_URLS = {"/user/info", "/login", "/logout", "/refresh"};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addInterceptors (InterceptorRegistry registry) {
|
|
||||||
registry.addInterceptor(getHeaderInterceptor())
|
|
||||||
.addPathPatterns("/**")
|
|
||||||
.excludePathPatterns(EXCLUDE_URLS)
|
|
||||||
.order(-10);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义请求头拦截器
|
|
||||||
*/
|
|
||||||
public SaaSInterceptor getHeaderInterceptor () {
|
|
||||||
return new SaaSInterceptor();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
com.muyu.cloud.common.saas.interceptor.WebMvcSaaSConfig
|
|
||||||
com.muyu.cloud.common.many.datasource.ManyDataSource
|
|
||||||
com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory
|
|
|
@ -28,7 +28,6 @@ public class HeaderInterceptor implements AsyncHandlerInterceptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
SecurityContextHolder.setUserId(ServletUtils.getHeader(request, SecurityConstants.DETAILS_USER_ID));
|
SecurityContextHolder.setUserId(ServletUtils.getHeader(request, SecurityConstants.DETAILS_USER_ID));
|
||||||
SecurityContextHolder.setSaasKey(ServletUtils.getHeader(request, SecurityConstants.SAAS_KEY));
|
|
||||||
SecurityContextHolder.setUserName(ServletUtils.getHeader(request, SecurityConstants.DETAILS_USERNAME));
|
SecurityContextHolder.setUserName(ServletUtils.getHeader(request, SecurityConstants.DETAILS_USERNAME));
|
||||||
SecurityContextHolder.setUserKey(ServletUtils.getHeader(request, SecurityConstants.USER_KEY));
|
SecurityContextHolder.setUserKey(ServletUtils.getHeader(request, SecurityConstants.USER_KEY));
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.common.system.domain.LoginUser;
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
@ -34,7 +34,7 @@ public class TokenService {
|
||||||
private final static long expireTime = CacheConstants.EXPIRATION;
|
private final static long expireTime = CacheConstants.EXPIRATION;
|
||||||
|
|
||||||
private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY;
|
private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY;
|
||||||
@Resource
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,11 +55,10 @@ public class TokenService {
|
||||||
claimsMap.put(SecurityConstants.USER_KEY, token);
|
claimsMap.put(SecurityConstants.USER_KEY, token);
|
||||||
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
|
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
|
||||||
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
|
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
|
||||||
claimsMap.put(SecurityConstants.SAAS_KEY,loginUser.getSysUser().getFirmCode());
|
|
||||||
// 接口返回信息
|
// 接口返回信息
|
||||||
Map<String, Object> rspMap = new HashMap<String, Object>();
|
Map<String, Object> rspMap = new HashMap<String, Object>();
|
||||||
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
|
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
|
||||||
rspMap.put("ent_code", loginUser.getSysUser().getFirmCode());
|
|
||||||
rspMap.put("expires_in", expireTime);
|
rspMap.put("expires_in", expireTime);
|
||||||
return rspMap;
|
return rspMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,6 @@ public class SecurityUtils {
|
||||||
return SecurityContextHolder.getUserName();
|
return SecurityContextHolder.getUserName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getSaasKey () {
|
|
||||||
return SecurityContextHolder.getSaasKey();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户key
|
* 获取用户key
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -63,6 +63,4 @@ public class LoginUser implements Serializable {
|
||||||
*/
|
*/
|
||||||
private SysUser sysUser;
|
private SysUser sysUser;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,6 @@ public class SysDept extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
private String firmCode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 祖级列表
|
* 祖级列表
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
package com.muyu.common.system.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: DongZeLiang
|
|
||||||
* @date: 2024/6/3
|
|
||||||
* @Description: 企业信息
|
|
||||||
* @Version: 1.0
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@TableName("sys_ent")
|
|
||||||
public class SysEnt {
|
|
||||||
@TableId( type = IdType.AUTO)
|
|
||||||
private Integer id;
|
|
||||||
|
|
||||||
private String entCode;
|
|
||||||
|
|
||||||
private String ip;
|
|
||||||
|
|
||||||
private Integer port;
|
|
||||||
|
|
||||||
private String dbName;
|
|
||||||
|
|
||||||
private String userName;
|
|
||||||
|
|
||||||
private String password;
|
|
||||||
}
|
|
|
@ -1,25 +0,0 @@
|
||||||
package com.muyu.common.system.domain;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author WangXin
|
|
||||||
* @Data 2024/9/18
|
|
||||||
* @Description 企业用户
|
|
||||||
* @Version 1.0.0
|
|
||||||
*/
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class SysFirmUser extends SysUser {
|
|
||||||
/**
|
|
||||||
* 用户数据库
|
|
||||||
*/
|
|
||||||
private String databaseName;
|
|
||||||
}
|
|
|
@ -36,8 +36,6 @@ public class SysRole extends BaseEntity {
|
||||||
@Excel(name = "角色名称")
|
@Excel(name = "角色名称")
|
||||||
private String roleName;
|
private String roleName;
|
||||||
|
|
||||||
private String firmCode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 角色权限
|
* 角色权限
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package com.muyu.common.system.domain;
|
package com.muyu.common.system.domain;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.annotation.Excel.ColumnType;
|
import com.muyu.common.core.annotation.Excel.ColumnType;
|
||||||
import com.muyu.common.core.annotation.Excel.Type;
|
import com.muyu.common.core.annotation.Excel.Type;
|
||||||
|
@ -31,7 +28,6 @@ import java.util.List;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@TableName("sys_user")
|
|
||||||
public class SysUser extends BaseEntity {
|
public class SysUser extends BaseEntity {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -39,11 +35,8 @@ public class SysUser extends BaseEntity {
|
||||||
* 用户ID
|
* 用户ID
|
||||||
*/
|
*/
|
||||||
@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
|
@Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
private Integer isAdmin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门ID
|
* 部门ID
|
||||||
*/
|
*/
|
||||||
|
@ -56,9 +49,6 @@ public class SysUser extends BaseEntity {
|
||||||
@Excel(name = "登录名称")
|
@Excel(name = "登录名称")
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
|
|
||||||
private String firmCode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户昵称
|
* 用户昵称
|
||||||
*/
|
*/
|
||||||
|
@ -145,8 +135,6 @@ public class SysUser extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private Long roleId;
|
private Long roleId;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public SysUser (Long userId) {
|
public SysUser (Long userId) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
}
|
}
|
||||||
|
@ -155,9 +143,8 @@ public class SysUser extends BaseEntity {
|
||||||
return userId != null && 1L == userId;
|
return userId != null && 1L == userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isAdmin () {
|
public boolean isAdmin () {
|
||||||
return isAdmin(this.userId) || (this.isAdmin != null && this.isAdmin == 1);
|
return isAdmin(this.userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Xss(message = "用户昵称不能包含脚本字符")
|
@Xss(message = "用户昵称不能包含脚本字符")
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
package com.muyu.common.system.domain;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户和岗位关联 sys_user_post
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class SysUserPost {
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 岗位ID
|
|
||||||
*/
|
|
||||||
private Long postId;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
package com.muyu.common.system.domain;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户和角色关联 sys_user_role
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Builder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class SysUserRole {
|
|
||||||
/**
|
|
||||||
* 用户ID
|
|
||||||
*/
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色ID
|
|
||||||
*/
|
|
||||||
private Long roleId;
|
|
||||||
}
|
|
|
@ -1,32 +0,0 @@
|
||||||
package com.muyu.common.system.remote;
|
|
||||||
|
|
||||||
import com.muyu.common.core.constant.SecurityConstants;
|
|
||||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.common.system.domain.SysUser;
|
|
||||||
import com.muyu.common.system.remote.factory.RemoteSaasFallbackFactory;
|
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestHeader;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 文件服务
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
*/
|
|
||||||
@FeignClient(contextId = "remoteSaasService", value = ServiceNameConstants.SAAS_SERVICE, fallbackFactory = RemoteSaasFallbackFactory.class)
|
|
||||||
public interface RemoteSaasService {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过用户名查询用户信息
|
|
||||||
*
|
|
||||||
* @param firmCode
|
|
||||||
* @param userName 用户名
|
|
||||||
* @param source 请求来源
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@GetMapping("/user/info")
|
|
||||||
public Result<SysUser> getUserInfo (@RequestParam("firmCode") String firmCode, @RequestParam("userName") String userName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,14 +3,12 @@ package com.muyu.common.system.remote;
|
||||||
import com.muyu.common.core.constant.SecurityConstants;
|
import com.muyu.common.core.constant.SecurityConstants;
|
||||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.system.domain.*;
|
import com.muyu.common.system.domain.SysUser;
|
||||||
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
|
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
|
||||||
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户服务
|
* 用户服务
|
||||||
*
|
*
|
||||||
|
@ -18,6 +16,16 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
|
@FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class)
|
||||||
public interface RemoteUserService {
|
public interface RemoteUserService {
|
||||||
|
/**
|
||||||
|
* 通过用户名查询用户信息
|
||||||
|
*
|
||||||
|
* @param username 用户名
|
||||||
|
* @param source 请求来源
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@GetMapping("/user/info/{username}")
|
||||||
|
public Result<LoginUser> getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册用户信息
|
* 注册用户信息
|
||||||
|
@ -29,73 +37,4 @@ public interface RemoteUserService {
|
||||||
*/
|
*/
|
||||||
@PostMapping("/user/register")
|
@PostMapping("/user/register")
|
||||||
public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||||
|
|
||||||
@GetMapping("/user/companyList")
|
|
||||||
public Result<List<SysUser>> companyList ();
|
|
||||||
|
|
||||||
@PostMapping("/ent/list")
|
|
||||||
public Result<List<SysEnt>> list (@RequestBody SysEnt sysEnt);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过用户名查询用户信息
|
|
||||||
*
|
|
||||||
* @param firmCode
|
|
||||||
* @param userName 用户名
|
|
||||||
* @param source 请求来源
|
|
||||||
* @return 结果
|
|
||||||
*/
|
|
||||||
@GetMapping("/user/info")
|
|
||||||
public Result<LoginUser> getUserInfo (@RequestParam("firmCode") String firmCode, @RequestParam("userName") String userName, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取角色数据权限
|
|
||||||
*
|
|
||||||
* @param user 用户
|
|
||||||
*
|
|
||||||
* @return 角色权限信息
|
|
||||||
*/
|
|
||||||
@PostMapping("/permission/getRole")
|
|
||||||
public Set<String> getRolePermission (@RequestBody SysUser user);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取菜单数据权限
|
|
||||||
*
|
|
||||||
* @param user 用户
|
|
||||||
*
|
|
||||||
* @return 菜单权限信息
|
|
||||||
*/
|
|
||||||
@PostMapping("/permission/getMenu")
|
|
||||||
public Set<String> getMenuPermission (@RequestBody SysUser user);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据部门编号获取详细信息
|
|
||||||
*/
|
|
||||||
@GetMapping(value = "/dept/{deptId}")
|
|
||||||
public Result<SysDept> selectDeptById (@PathVariable("deptId") Long deptId);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增用户角色信息
|
|
||||||
*
|
|
||||||
* @param user 用户对象
|
|
||||||
*/
|
|
||||||
@PostMapping("/user/insertUserRole")
|
|
||||||
public void insertUserRole (@RequestBody SysUser user);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增用户岗位信息
|
|
||||||
*
|
|
||||||
* @param user 用户对象
|
|
||||||
*/
|
|
||||||
@PostMapping("/user/insertUserPost")
|
|
||||||
public void insertUserPost (@RequestBody SysUser user);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册用户
|
|
||||||
*/
|
|
||||||
@PostMapping("/user")
|
|
||||||
public Result addUser (@RequestBody SysUser user);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
package com.muyu.common.system.remote.factory;
|
|
||||||
/**
|
|
||||||
* @Author: 胡杨
|
|
||||||
* @Name: RemoteEntFallbackFactory
|
|
||||||
* @Description:
|
|
||||||
* @CreatedDate: 2024/9/20 下午3:11
|
|
||||||
* @FilePath: com.muyu.common.system.remote
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.common.system.domain.SysUser;
|
|
||||||
import com.muyu.common.system.remote.RemoteSaasService;
|
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: 胡杨
|
|
||||||
* @Name: RemoteEntFallbackFactory
|
|
||||||
* @Description:
|
|
||||||
* @CreatedDate: 2024/9/20 下午3:11
|
|
||||||
* @FilePath: com.muyu.common.system.remote
|
|
||||||
*/
|
|
||||||
@Component
|
|
||||||
public class RemoteSaasFallbackFactory implements FallbackFactory<RemoteSaasService> {
|
|
||||||
@Override
|
|
||||||
public RemoteSaasService create(Throwable cause) {
|
|
||||||
return new RemoteSaasService() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<SysUser> getUserInfo(String firmCode, String username, String source) {
|
|
||||||
return Result.error("获取用户失败:" + cause.getMessage());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,17 +1,14 @@
|
||||||
package com.muyu.common.system.remote.factory;
|
package com.muyu.common.system.remote.factory;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
|
||||||
import com.muyu.common.system.domain.*;
|
|
||||||
import com.muyu.common.system.remote.RemoteUserService;
|
import com.muyu.common.system.remote.RemoteUserService;
|
||||||
|
import com.muyu.common.system.domain.SysUser;
|
||||||
|
import com.muyu.common.system.domain.LoginUser;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户服务降级处理
|
* 用户服务降级处理
|
||||||
*
|
*
|
||||||
|
@ -25,57 +22,15 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
||||||
public RemoteUserService create (Throwable throwable) {
|
public RemoteUserService create (Throwable throwable) {
|
||||||
log.error("用户服务调用失败:{}", throwable.getMessage());
|
log.error("用户服务调用失败:{}", throwable.getMessage());
|
||||||
return new RemoteUserService() {
|
return new RemoteUserService() {
|
||||||
|
@Override
|
||||||
|
public Result<LoginUser> getUserInfo (String username, String source) {
|
||||||
|
return Result.error("获取用户失败:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<Boolean> registerUserInfo (SysUser sysUser, String source) {
|
public Result<Boolean> registerUserInfo (SysUser sysUser, String source) {
|
||||||
return Result.error("注册用户失败:" + throwable.getMessage());
|
return Result.error("注册用户失败:" + throwable.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<List<SysUser>> companyList() {
|
|
||||||
return Result.error("获取企业列表失败:" + throwable.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<List<SysEnt>> list(SysEnt sysEnt) {
|
|
||||||
return Result.error("获取企业列表失败:" + throwable.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<LoginUser> getUserInfo(String firmCode, String userName, String source) {
|
|
||||||
return Result.error("获取用户信息失败:" + throwable.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<String> getRolePermission(SysUser user) {
|
|
||||||
return Set.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<String> getMenuPermission(SysUser user) {
|
|
||||||
return Set.of();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<SysDept> selectDeptById(Long deptId) {
|
|
||||||
return Result.error();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void insertUserRole(SysUser user) {
|
|
||||||
log.warn("新增用户角色失败!");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void insertUserPost(SysUser user) {
|
|
||||||
log.warn("新增用户权限失败!");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result addUser(SysUser user) {
|
|
||||||
return Result.error(throwable);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
com.muyu.common.system.remote.factory.RemoteUserFallbackFactory
|
com.muyu.common.system.remote.factory.RemoteUserFallbackFactory
|
||||||
com.muyu.common.system.remote.factory.RemoteLogFallbackFactory
|
com.muyu.common.system.remote.factory.RemoteLogFallbackFactory
|
||||||
com.muyu.common.system.remote.factory.RemoteFileFallbackFactory
|
com.muyu.common.system.remote.factory.RemoteFileFallbackFactory
|
||||||
com.muyu.common.system.remote.factory.RemoteSaasFallbackFactory
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Log4j2
|
@Log4j2
|
||||||
//@Component
|
@Component
|
||||||
public class XXLJobConfig {
|
public class XXLJobConfig {
|
||||||
// @Bean
|
@Bean
|
||||||
public XxlJobSpringExecutor xxlJobExecutor(XxlJobProperties xxlJobProperties) {
|
public XxlJobSpringExecutor xxlJobExecutor(XxlJobProperties xxlJobProperties) {
|
||||||
if (StringUtils.isEmpty(xxlJobProperties.getAdminAddresses())){
|
if (StringUtils.isEmpty(xxlJobProperties.getAdminAddresses())){
|
||||||
throw new RuntimeException("请在bootstrap.yml当中配置shared-configs项,xxl-job共享配置[application-xxl-config]");
|
throw new RuntimeException("请在bootstrap.yml当中配置shared-configs项,xxl-job共享配置[application-xxl-config]");
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
<module>cloud-common-system</module>
|
<module>cloud-common-system</module>
|
||||||
<module>cloud-common-xxl</module>
|
<module>cloud-common-xxl</module>
|
||||||
<module>cloud-common-rabbit</module>
|
<module>cloud-common-rabbit</module>
|
||||||
<module>cloud-common-saas</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>cloud-common</artifactId>
|
<artifactId>cloud-common</artifactId>
|
||||||
|
|
|
@ -81,6 +81,7 @@
|
||||||
<artifactId>knife4j-gateway-spring-boot-starter</artifactId>
|
<artifactId>knife4j-gateway-spring-boot-starter</artifactId>
|
||||||
<version>4.5.0</version>
|
<version>4.5.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -13,6 +13,5 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
public class CloudGatewayApplication {
|
public class CloudGatewayApplication {
|
||||||
public static void main (String[] args) {
|
public static void main (String[] args) {
|
||||||
SpringApplication.run(CloudGatewayApplication.class, args);
|
SpringApplication.run(CloudGatewayApplication.class, args);
|
||||||
System.out.println("CloudGateway 模块启动成功!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.muyu.gateway.config;
|
package com.muyu.gateway.config;
|
||||||
|
|
||||||
import com.muyu.gateway.handler.ValidateCodeHandler;
|
import com.muyu.gateway.handler.ValidateCodeHandler;
|
||||||
import javax.annotation.Resource;
|
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.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
|
@ -16,7 +16,7 @@ import org.springframework.web.reactive.function.server.RouterFunctions;
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class RouterFunctionConfiguration {
|
public class RouterFunctionConfiguration {
|
||||||
@Resource
|
@Autowired
|
||||||
private ValidateCodeHandler validateCodeHandler;
|
private ValidateCodeHandler validateCodeHandler;
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
|
|
|
@ -12,7 +12,7 @@ import com.muyu.gateway.config.properties.IgnoreWhiteProperties;
|
||||||
import io.jsonwebtoken.Claims;
|
import io.jsonwebtoken.Claims;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||||
import org.springframework.core.Ordered;
|
import org.springframework.core.Ordered;
|
||||||
|
@ -31,10 +31,10 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
||||||
private static final Logger log = LoggerFactory.getLogger(AuthFilter.class);
|
private static final Logger log = LoggerFactory.getLogger(AuthFilter.class);
|
||||||
|
|
||||||
// 排除过滤的 uri 地址,nacos自行添加
|
// 排除过滤的 uri 地址,nacos自行添加
|
||||||
@Resource
|
@Autowired
|
||||||
private IgnoreWhiteProperties ignoreWhite;
|
private IgnoreWhiteProperties ignoreWhite;
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +63,6 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
||||||
}
|
}
|
||||||
String userid = JwtUtils.getUserId(claims);
|
String userid = JwtUtils.getUserId(claims);
|
||||||
String username = JwtUtils.getUserName(claims);
|
String username = JwtUtils.getUserName(claims);
|
||||||
String saasKey = JwtUtils.getSaasKey(claims);
|
|
||||||
if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) {
|
if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) {
|
||||||
return unauthorizedResponse(exchange, "令牌验证失败");
|
return unauthorizedResponse(exchange, "令牌验证失败");
|
||||||
}
|
}
|
||||||
|
@ -72,7 +71,6 @@ public class AuthFilter implements GlobalFilter, Ordered {
|
||||||
addHeader(mutate, SecurityConstants.USER_KEY, userkey);
|
addHeader(mutate, SecurityConstants.USER_KEY, userkey);
|
||||||
addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid);
|
addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid);
|
||||||
addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username);
|
addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username);
|
||||||
addHeader(mutate,SecurityConstants.SAAS_KEY,saasKey);
|
|
||||||
// 内部请求来源参数清除
|
// 内部请求来源参数清除
|
||||||
removeHeader(mutate, SecurityConstants.FROM_SOURCE);
|
removeHeader(mutate, SecurityConstants.FROM_SOURCE);
|
||||||
return chain.filter(exchange.mutate().request(mutate.build()).build());
|
return chain.filter(exchange.mutate().request(mutate.build()).build());
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.muyu.common.core.utils.ServletUtils;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.gateway.config.properties.CaptchaProperties;
|
import com.muyu.gateway.config.properties.CaptchaProperties;
|
||||||
import com.muyu.gateway.service.ValidateCodeService;
|
import com.muyu.gateway.service.ValidateCodeService;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
import org.springframework.cloud.gateway.filter.GatewayFilter;
|
||||||
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
|
||||||
import org.springframework.core.io.buffer.DataBuffer;
|
import org.springframework.core.io.buffer.DataBuffer;
|
||||||
|
@ -29,9 +29,9 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory<Object> {
|
||||||
private final static String[] VALIDATE_URL = new String[]{"/auth/login", "/auth/register"};
|
private final static String[] VALIDATE_URL = new String[]{"/auth/login", "/auth/register"};
|
||||||
private static final String CODE = "code";
|
private static final String CODE = "code";
|
||||||
private static final String UUID = "uuid";
|
private static final String UUID = "uuid";
|
||||||
@Resource
|
@Autowired
|
||||||
private ValidateCodeService validateCodeService;
|
private ValidateCodeService validateCodeService;
|
||||||
@Resource
|
@Autowired
|
||||||
private CaptchaProperties captchaProperties;
|
private CaptchaProperties captchaProperties;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.core.utils.html.EscapeUtil;
|
import com.muyu.common.core.utils.html.EscapeUtil;
|
||||||
import com.muyu.gateway.config.properties.XssProperties;
|
import com.muyu.gateway.config.properties.XssProperties;
|
||||||
import io.netty.buffer.ByteBufAllocator;
|
import io.netty.buffer.ByteBufAllocator;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||||
|
@ -31,7 +31,7 @@ import java.nio.charset.StandardCharsets;
|
||||||
@ConditionalOnProperty(value = "security.xss.enabled", havingValue = "true")
|
@ConditionalOnProperty(value = "security.xss.enabled", havingValue = "true")
|
||||||
public class XssFilter implements GlobalFilter, Ordered {
|
public class XssFilter implements GlobalFilter, Ordered {
|
||||||
// 跨站脚本的 xss 配置,nacos自行添加
|
// 跨站脚本的 xss 配置,nacos自行添加
|
||||||
@Resource
|
@Autowired
|
||||||
private XssProperties xss;
|
private XssProperties xss;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.muyu.gateway.handler;
|
||||||
import com.muyu.common.core.exception.CaptchaException;
|
import com.muyu.common.core.exception.CaptchaException;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.gateway.service.ValidateCodeService;
|
import com.muyu.gateway.service.ValidateCodeService;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.reactive.function.BodyInserters;
|
import org.springframework.web.reactive.function.BodyInserters;
|
||||||
|
@ -21,7 +21,7 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class ValidateCodeHandler implements HandlerFunction<ServerResponse> {
|
public class ValidateCodeHandler implements HandlerFunction<ServerResponse> {
|
||||||
@Resource
|
@Autowired
|
||||||
private ValidateCodeService validateCodeService;
|
private ValidateCodeService validateCodeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -12,7 +12,7 @@ import com.muyu.common.redis.service.RedisService;
|
||||||
import com.muyu.gateway.config.properties.CaptchaProperties;
|
import com.muyu.gateway.config.properties.CaptchaProperties;
|
||||||
import com.muyu.gateway.model.resp.CaptchaCodeResp;
|
import com.muyu.gateway.model.resp.CaptchaCodeResp;
|
||||||
import com.muyu.gateway.service.ValidateCodeService;
|
import com.muyu.gateway.service.ValidateCodeService;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.FastByteArrayOutputStream;
|
import org.springframework.util.FastByteArrayOutputStream;
|
||||||
|
|
||||||
|
@ -35,10 +35,10 @@ public class ValidateCodeServiceImpl implements ValidateCodeService {
|
||||||
@Resource(name = "captchaProducerMath")
|
@Resource(name = "captchaProducerMath")
|
||||||
private Producer captchaProducerMath;
|
private Producer captchaProducerMath;
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private CaptchaProperties captchaProperties;
|
private CaptchaProperties captchaProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,7 +50,7 @@ public class ValidateCodeServiceImpl implements ValidateCodeService {
|
||||||
CaptchaCodeResp.CaptchaCodeRespBuilder respBuilder = CaptchaCodeResp.builder()
|
CaptchaCodeResp.CaptchaCodeRespBuilder respBuilder = CaptchaCodeResp.builder()
|
||||||
.captchaEnabled(captchaEnabled);
|
.captchaEnabled(captchaEnabled);
|
||||||
if (!captchaEnabled) {
|
if (!captchaEnabled) {
|
||||||
return Result.success(respBuilder.build());
|
return Result.success(respBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存验证码信息
|
// 保存验证码信息
|
||||||
|
|
|
@ -4,6 +4,8 @@ import cn.hutool.core.net.NetUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.cloud.gateway.route.Route;
|
import org.springframework.cloud.gateway.route.Route;
|
||||||
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
|
||||||
import org.springframework.core.io.buffer.DataBufferFactory;
|
import org.springframework.core.io.buffer.DataBufferFactory;
|
||||||
|
@ -16,6 +18,8 @@ import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Web 工具类
|
* Web 工具类
|
||||||
|
*
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class WebFrameworkUtils {
|
public class WebFrameworkUtils {
|
||||||
|
@ -68,6 +72,8 @@ public class WebFrameworkUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得客户端 IP
|
* 获得客户端 IP
|
||||||
|
*
|
||||||
|
*
|
||||||
* @param exchange 请求
|
* @param exchange 请求
|
||||||
* @param otherHeaderNames 其它 header 名字的数组
|
* @param otherHeaderNames 其它 header 名字的数组
|
||||||
* @return 客户端 IP
|
* @return 客户端 IP
|
||||||
|
@ -85,6 +91,7 @@ public class WebFrameworkUtils {
|
||||||
return NetUtil.getMultistageReverseProxyIp(ip);
|
return NetUtil.getMultistageReverseProxyIp(ip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 方式二,通过 remoteAddress 获取
|
// 方式二,通过 remoteAddress 获取
|
||||||
if (exchange.getRequest().getRemoteAddress() == null) {
|
if (exchange.getRequest().getRemoteAddress() == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -95,6 +102,7 @@ public class WebFrameworkUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得请求匹配的 Route 路由
|
* 获得请求匹配的 Route 路由
|
||||||
|
*
|
||||||
* @param exchange 请求
|
* @param exchange 请求
|
||||||
* @return 路由
|
* @return 路由
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,10 +4,10 @@ server:
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 110.42.213.184:8848
|
addr: nacos.muyu.icu:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: icecream
|
namespace: muyu-cloud
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
@ -22,29 +22,29 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: ${nacos.addr}
|
server-addr: ${nacos.addr}
|
||||||
# # nacos用户名
|
# nacos用户名
|
||||||
# username: ${nacos.user-name}
|
username: ${nacos.user-name}
|
||||||
# # nacos密码
|
# nacos密码
|
||||||
# password: ${nacos.password}
|
password: ${nacos.password}
|
||||||
# 命名空间
|
# 命名空间
|
||||||
namespace: ${nacos.namespace}
|
namespace: ${nacos.namespace}
|
||||||
config:
|
config:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: ${nacos.addr}
|
server-addr: ${nacos.addr}
|
||||||
# # nacos用户名
|
# nacos用户名
|
||||||
# username: ${nacos.user-name}
|
username: ${nacos.user-name}
|
||||||
# # nacos密码
|
# nacos密码
|
||||||
# password: ${nacos.password}
|
password: ${nacos.password}
|
||||||
# 命名空间
|
# 命名空间
|
||||||
namespace: ${nacos.namespace}
|
namespace: ${nacos.namespace}
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
# 系统环境Config共享配置
|
|
||||||
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
# 系统共享配置
|
# 系统共享配置
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# 系统环境Config共享配置
|
||||||
|
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
sentinel:
|
sentinel:
|
||||||
# 取消控制台懒加载
|
# 取消控制台懒加载
|
||||||
eager: true
|
eager: true
|
||||||
|
|
|
@ -13,7 +13,5 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
public class CloudFileApplication {
|
public class CloudFileApplication {
|
||||||
public static void main (String[] args) {
|
public static void main (String[] args) {
|
||||||
SpringApplication.run(CloudFileApplication.class, args);
|
SpringApplication.run(CloudFileApplication.class, args);
|
||||||
System.out.println("CloudFile 模块启动成功!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.muyu.file.service.ISysFileService;
|
||||||
import com.muyu.common.system.domain.SysFile;
|
import com.muyu.common.system.domain.SysFile;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
@ -21,7 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||||
public class SysFileController {
|
public class SysFileController {
|
||||||
private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
|
private static final Logger log = LoggerFactory.getLogger(SysFileController.class);
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private ISysFileService sysFileService;
|
private ISysFileService sysFileService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,7 +5,7 @@ import com.muyu.file.config.MinioConfig;
|
||||||
import com.muyu.file.utils.FileUploadUtils;
|
import com.muyu.file.utils.FileUploadUtils;
|
||||||
import io.minio.MinioClient;
|
import io.minio.MinioClient;
|
||||||
import io.minio.PutObjectArgs;
|
import io.minio.PutObjectArgs;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@ -18,10 +18,10 @@ import java.io.InputStream;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class MinioSysFileServiceImpl implements ISysFileService {
|
public class MinioSysFileServiceImpl implements ISysFileService {
|
||||||
@Resource
|
@Autowired
|
||||||
private MinioConfig minioConfig;
|
private MinioConfig minioConfig;
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private MinioClient client;
|
private MinioClient client;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
# Tomcat
|
# Tomcat
|
||||||
server:
|
server:
|
||||||
port: 9301
|
port: 9300
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 110.42.213.184:8848
|
addr: nacos.muyu.icu:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: icecream
|
namespace: muyu-cloud
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
@ -23,18 +23,18 @@ spring:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: ${nacos.addr}
|
server-addr: ${nacos.addr}
|
||||||
# nacos用户名
|
# nacos用户名
|
||||||
# username: ${nacos.user-name}
|
username: ${nacos.user-name}
|
||||||
# # nacos密码
|
# nacos密码
|
||||||
# password: ${nacos.password}
|
password: ${nacos.password}
|
||||||
# 命名空间
|
# 命名空间
|
||||||
namespace: ${nacos.namespace}
|
namespace: ${nacos.namespace}
|
||||||
config:
|
config:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: ${nacos.addr}
|
server-addr: ${nacos.addr}
|
||||||
# nacos用户名
|
# nacos用户名
|
||||||
# username: ${nacos.user-name}
|
username: ${nacos.user-name}
|
||||||
# # nacos密码
|
# nacos密码
|
||||||
# password: ${nacos.password}
|
password: ${nacos.password}
|
||||||
# 命名空间
|
# 命名空间
|
||||||
namespace: ${nacos.namespace}
|
namespace: ${nacos.namespace}
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
|
|
|
@ -16,6 +16,5 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
public class CloudGenApplication {
|
public class CloudGenApplication {
|
||||||
public static void main (String[] args) {
|
public static void main (String[] args) {
|
||||||
SpringApplication.run(CloudGenApplication.class, args);
|
SpringApplication.run(CloudGenApplication.class, args);
|
||||||
System.out.println("CloudGen 模块启动成功!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,22 @@
|
||||||
package com.muyu.gen.controller;
|
package com.muyu.gen.controller;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
|
||||||
import com.muyu.common.core.text.Convert;
|
import com.muyu.common.core.text.Convert;
|
||||||
import com.muyu.common.core.web.controller.BaseController;
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
import com.muyu.common.log.annotation.Log;
|
import com.muyu.common.log.annotation.Log;
|
||||||
import com.muyu.common.log.enums.BusinessType;
|
import com.muyu.common.log.enums.BusinessType;
|
||||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
import com.muyu.gen.domain.GenTable;
|
import com.muyu.gen.domain.GenTable;
|
||||||
import com.muyu.gen.domain.GenTableColumn;
|
import com.muyu.gen.domain.GenTableColumn;
|
||||||
import com.muyu.gen.domain.GenTableResp;
|
|
||||||
import com.muyu.gen.service.IGenTableColumnService;
|
import com.muyu.gen.service.IGenTableColumnService;
|
||||||
import com.muyu.gen.service.IGenTableService;
|
import com.muyu.gen.service.IGenTableService;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -27,19 +25,15 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* 代码生成 操作处理
|
* 代码生成 操作处理
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/gen")
|
@RequestMapping("/gen")
|
||||||
@RestController
|
@RestController
|
||||||
public class GenController extends BaseController
|
public class GenController extends BaseController {
|
||||||
{
|
@Autowired
|
||||||
@Resource
|
|
||||||
private IGenTableService genTableService;
|
private IGenTableService genTableService;
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private HttpServletResponse response;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private IGenTableColumnService genTableColumnService;
|
private IGenTableColumnService genTableColumnService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,8 +41,7 @@ public class GenController extends BaseController
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("tool:gen:list")
|
@RequiresPermissions("tool:gen:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result genList(GenTable genTable)
|
public Result<TableDataInfo<GenTable>> genList (GenTable genTable) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<GenTable> list = genTableService.selectGenTableList(genTable);
|
List<GenTable> list = genTableService.selectGenTableList(genTable);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
|
@ -59,8 +52,7 @@ public class GenController extends BaseController
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("tool:gen:query")
|
@RequiresPermissions("tool:gen:query")
|
||||||
@GetMapping(value = "/{tableId}")
|
@GetMapping(value = "/{tableId}")
|
||||||
public Result getInfo(@PathVariable("tableId") Long tableId)
|
public Result getInfo (@PathVariable("tableId") Long tableId) {
|
||||||
{
|
|
||||||
GenTable table = genTableService.selectGenTableById(tableId);
|
GenTable table = genTableService.selectGenTableById(tableId);
|
||||||
List<GenTable> tables = genTableService.selectGenTableAll();
|
List<GenTable> tables = genTableService.selectGenTableAll();
|
||||||
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
|
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
|
||||||
|
@ -71,14 +63,12 @@ public class GenController extends BaseController
|
||||||
return success(map);
|
return success(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询数据库列表
|
* 查询数据库列表
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("tool:gen:list")
|
@RequiresPermissions("tool:gen:list")
|
||||||
@GetMapping("/db/list")
|
@GetMapping("/db/list")
|
||||||
public Result dataList(GenTable genTable)
|
public Result<TableDataInfo<GenTable>> dataList (GenTable genTable) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<GenTable> list = genTableService.selectDbTableList(genTable);
|
List<GenTable> list = genTableService.selectDbTableList(genTable);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
|
@ -88,26 +78,26 @@ public class GenController extends BaseController
|
||||||
* 查询数据表字段列表
|
* 查询数据表字段列表
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/column/{tableId}")
|
@GetMapping(value = "/column/{tableId}")
|
||||||
public Result columnList(@PathVariable("tableId") Long tableId)
|
public Result<TableDataInfo<GenTableColumn>> columnList (Long tableId) {
|
||||||
{
|
|
||||||
TableDataInfo dataInfo = new TableDataInfo();
|
|
||||||
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
|
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
|
||||||
dataInfo.setRows(list);
|
return Result.success(
|
||||||
dataInfo.setTotal(list.size());
|
TableDataInfo.<GenTableColumn>builder()
|
||||||
return success(dataInfo);
|
.total(list.size())
|
||||||
|
.rows(list)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入表结构(保存)
|
* 导入表结构(保存)
|
||||||
*/
|
*/
|
||||||
// @RequiresPermissions("tool:gen:import")
|
@RequiresPermissions("tool:gen:import")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
||||||
@PostMapping("/importTable")
|
@PostMapping("/importTable")
|
||||||
public Result importTableSave(@RequestParam("tables") String tables, @RequestParam("dbName") String dbName)
|
public Result importTableSave (String tables) {
|
||||||
{
|
|
||||||
String[] tableNames = Convert.toStrArray(tables);
|
String[] tableNames = Convert.toStrArray(tables);
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames,dbName);
|
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
||||||
genTableService.importGenTable(tableList);
|
genTableService.importGenTable(tableList);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
@ -118,8 +108,7 @@ public class GenController extends BaseController
|
||||||
@RequiresPermissions("tool:gen:edit")
|
@RequiresPermissions("tool:gen:edit")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public Result editSave(@Validated @RequestBody GenTable genTable)
|
public Result editSave (@Validated @RequestBody GenTable genTable) {
|
||||||
{
|
|
||||||
genTableService.validateEdit(genTable);
|
genTableService.validateEdit(genTable);
|
||||||
genTableService.updateGenTable(genTable);
|
genTableService.updateGenTable(genTable);
|
||||||
return success();
|
return success();
|
||||||
|
@ -131,8 +120,7 @@ public class GenController extends BaseController
|
||||||
@RequiresPermissions("tool:gen:remove")
|
@RequiresPermissions("tool:gen:remove")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.DELETE)
|
@Log(title = "代码生成", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{tableIds}")
|
@DeleteMapping("/{tableIds}")
|
||||||
public Result remove(@PathVariable("tableIds") Long[] tableIds)
|
public Result remove (@PathVariable("tableIds") Long[] tableIds) {
|
||||||
{
|
|
||||||
genTableService.deleteGenTableByIds(tableIds);
|
genTableService.deleteGenTableByIds(tableIds);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
@ -142,8 +130,7 @@ public class GenController extends BaseController
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("tool:gen:preview")
|
@RequiresPermissions("tool:gen:preview")
|
||||||
@GetMapping("/preview/{tableId}")
|
@GetMapping("/preview/{tableId}")
|
||||||
public Result preview(@PathVariable("tableId") Long tableId) throws IOException
|
public Result preview (@PathVariable("tableId") Long tableId) throws IOException {
|
||||||
{
|
|
||||||
Map<String, String> dataMap = genTableService.previewCode(tableId);
|
Map<String, String> dataMap = genTableService.previewCode(tableId);
|
||||||
return success(dataMap);
|
return success(dataMap);
|
||||||
}
|
}
|
||||||
|
@ -154,8 +141,7 @@ public class GenController extends BaseController
|
||||||
@RequiresPermissions("tool:gen:code")
|
@RequiresPermissions("tool:gen:code")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
||||||
@GetMapping("/download/{tableName}")
|
@GetMapping("/download/{tableName}")
|
||||||
public void download(@PathVariable("tableName") String tableName) throws IOException
|
public void download (HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
|
||||||
{
|
|
||||||
byte[] data = genTableService.downloadCode(tableName);
|
byte[] data = genTableService.downloadCode(tableName);
|
||||||
genCode(response, data);
|
genCode(response, data);
|
||||||
}
|
}
|
||||||
|
@ -166,8 +152,7 @@ public class GenController extends BaseController
|
||||||
@RequiresPermissions("tool:gen:code")
|
@RequiresPermissions("tool:gen:code")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
||||||
@GetMapping("/genCode/{tableName}")
|
@GetMapping("/genCode/{tableName}")
|
||||||
public Result genCode(@PathVariable("tableName") String tableName)
|
public Result genCode (@PathVariable("tableName") String tableName) {
|
||||||
{
|
|
||||||
genTableService.generatorCode(tableName);
|
genTableService.generatorCode(tableName);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
@ -177,10 +162,9 @@ public class GenController extends BaseController
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("tool:gen:edit")
|
@RequiresPermissions("tool:gen:edit")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
||||||
@GetMapping("/synchDb/{tableName}/{dbName}")
|
@GetMapping("/synchDb/{tableName}")
|
||||||
public Result synchDb(@PathVariable("tableName") String tableName,@PathVariable("dbName") String dbName)
|
public Result synchDb (@PathVariable("tableName") String tableName) {
|
||||||
{
|
genTableService.synchDb(tableName);
|
||||||
genTableService.synchDb(tableName,dbName);
|
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,8 +174,7 @@ public class GenController extends BaseController
|
||||||
@RequiresPermissions("tool:gen:code")
|
@RequiresPermissions("tool:gen:code")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
||||||
@GetMapping("/batchGenCode")
|
@GetMapping("/batchGenCode")
|
||||||
public void batchGenCode(@RequestParam("tables") String tables) throws IOException
|
public void batchGenCode (HttpServletResponse response, String tables) throws IOException {
|
||||||
{
|
|
||||||
String[] tableNames = Convert.toStrArray(tables);
|
String[] tableNames = Convert.toStrArray(tables);
|
||||||
byte[] data = genTableService.downloadCode(tableNames);
|
byte[] data = genTableService.downloadCode(tableNames);
|
||||||
genCode(response, data);
|
genCode(response, data);
|
||||||
|
@ -200,37 +183,11 @@ public class GenController extends BaseController
|
||||||
/**
|
/**
|
||||||
* 生成zip文件
|
* 生成zip文件
|
||||||
*/
|
*/
|
||||||
private void genCode(HttpServletResponse response, byte[] data) throws IOException
|
private void genCode (HttpServletResponse response, byte[] data) throws IOException {
|
||||||
{
|
|
||||||
response.reset();
|
response.reset();
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\"");
|
response.setHeader("Content-Disposition", "attachment; filename=\"muyu.zip\"");
|
||||||
response.addHeader("Content-Length", "" + data.length);
|
response.addHeader("Content-Length", String.valueOf(data.length));
|
||||||
response.setContentType("application/octet-stream; charset=UTF-8");
|
response.setContentType("application/octet-stream; charset=UTF-8");
|
||||||
IOUtils.write(data, response.getOutputStream());
|
IOUtils.write(data, response.getOutputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有数据库名称
|
|
||||||
*/
|
|
||||||
@GetMapping("/db/selDbNameAll")
|
|
||||||
public Result<List<String>> selDbNameAll(){
|
|
||||||
return Result.success(genTableService.selDbNameAll());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有表,不分数据库
|
|
||||||
*/
|
|
||||||
@GetMapping("/db/listAll")
|
|
||||||
public Result<List<GenTableResp>> genListAll() {
|
|
||||||
return success(genTableService.selectDbTableListAll());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据数据库名称与表名称查询表字段
|
|
||||||
*/
|
|
||||||
@GetMapping("/selectDbTableColumnsByName")
|
|
||||||
public Result<List<GenTableColumn>> selTableAll(@RequestParam("dbName") String dbName,@RequestParam("table") String table){
|
|
||||||
List<GenTableColumn> genTableColumns = genTableColumnService.selectDbTableColumnsByName(table, dbName);
|
|
||||||
return Result.success(genTableColumns);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,6 @@ public class GenTable extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private Long tableId;
|
private Long tableId;
|
||||||
|
|
||||||
private String dbName;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表名称
|
* 表名称
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
package com.muyu.gen.domain;
|
|
||||||
|
|
||||||
import com.muyu.common.core.constant.GenConstants;
|
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务表 gen_table
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class GenTableResp extends BaseEntity {
|
|
||||||
|
|
||||||
private String dbName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表名称
|
|
||||||
*/
|
|
||||||
private String tableName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 表描述
|
|
||||||
*/
|
|
||||||
private String tableComment;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,64 +1,67 @@
|
||||||
package com.muyu.gen.mapper;
|
package com.muyu.gen.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.gen.domain.GenTableColumn;
|
import com.muyu.gen.domain.GenTableColumn;
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务字段 数据层
|
* 业务字段 数据层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
public interface GenTableColumnMapper
|
public interface GenTableColumnMapper extends BaseMapper<GenTableColumn> {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 根据表名称查询列信息
|
* 根据表名称查询列信息
|
||||||
*
|
*
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
* @param dbName
|
*
|
||||||
* @return 列信息
|
* @return 列信息
|
||||||
*/
|
*/
|
||||||
public List<GenTableColumn> selectDbTableColumnsByName(@Param("tableName") String tableName, @Param("dbName") String dbName);
|
List<GenTableColumn> selectDbTableColumnsByName (String tableName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询业务字段列表
|
* 查询业务字段列表
|
||||||
*
|
*
|
||||||
* @param tableId 业务字段编号
|
* @param tableId 业务字段编号
|
||||||
|
*
|
||||||
* @return 业务字段集合
|
* @return 业务字段集合
|
||||||
*/
|
*/
|
||||||
public List<GenTableColumn> selectGenTableColumnListByTableId(@Param("tableId") Long tableId);
|
List<GenTableColumn> selectGenTableColumnListByTableId (Long tableId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增业务字段
|
* 新增业务字段
|
||||||
*
|
*
|
||||||
* @param genTableColumn 业务字段信息
|
* @param genTableColumn 业务字段信息
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertGenTableColumn(GenTableColumn genTableColumn);
|
int insertGenTableColumn (GenTableColumn genTableColumn);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改业务字段
|
* 修改业务字段
|
||||||
*
|
*
|
||||||
* @param genTableColumn 业务字段信息
|
* @param genTableColumn 业务字段信息
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int updateGenTableColumn(GenTableColumn genTableColumn);
|
int updateGenTableColumn (GenTableColumn genTableColumn);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除业务字段
|
* 删除业务字段
|
||||||
*
|
*
|
||||||
* @param genTableColumns 列数据
|
* @param genTableColumns 列数据
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteGenTableColumns(@Param("genTableColumns") List<GenTableColumn> genTableColumns);
|
int deleteGenTableColumns (List<GenTableColumn> genTableColumns);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除业务字段
|
* 批量删除业务字段
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的数据ID
|
* @param ids 需要删除的数据ID
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteGenTableColumnByIds(@Param("ids") Long[] ids);
|
int deleteGenTableColumnByIds (Long[] ids);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,91 +1,92 @@
|
||||||
package com.muyu.gen.mapper;
|
package com.muyu.gen.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.gen.domain.GenTable;
|
import com.muyu.gen.domain.GenTable;
|
||||||
import com.muyu.gen.domain.GenTableResp;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务 数据层
|
* 业务 数据层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
public interface GenTableMapper
|
public interface GenTableMapper extends BaseMapper<GenTable> {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 查询业务列表
|
* 查询业务列表
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
|
*
|
||||||
* @return 业务集合
|
* @return 业务集合
|
||||||
*/
|
*/
|
||||||
public List<GenTable> selectGenTableList(GenTable genTable);
|
List<GenTable> selectGenTableList (GenTable genTable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询据库列表
|
* 查询据库列表
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
|
*
|
||||||
* @return 数据库表集合
|
* @return 数据库表集合
|
||||||
*/
|
*/
|
||||||
public List<GenTable> selectDbTableList(GenTable genTable);
|
List<GenTable> selectDbTableList (GenTable genTable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询据库列表
|
* 查询据库列表
|
||||||
*
|
*
|
||||||
* @param tableNames 表名称组
|
* @param tableNames 表名称组
|
||||||
* @param dbName
|
*
|
||||||
* @return 数据库表集合
|
* @return 数据库表集合
|
||||||
*/
|
*/
|
||||||
public List<GenTable> selectDbTableListByNames(@Param("tableNames") String[] tableNames, @Param("dbName") String dbName);
|
List<GenTable> selectDbTableListByNames (String[] tableNames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有表信息
|
* 查询所有表信息
|
||||||
*
|
*
|
||||||
* @return 表信息集合
|
* @return 表信息集合
|
||||||
*/
|
*/
|
||||||
public List<GenTable> selectGenTableAll();
|
List<GenTable> selectGenTableAll ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询表ID业务信息
|
* 查询表ID业务信息
|
||||||
*
|
*
|
||||||
* @param id 业务ID
|
* @param id 业务ID
|
||||||
|
*
|
||||||
* @return 业务信息
|
* @return 业务信息
|
||||||
*/
|
*/
|
||||||
public GenTable selectGenTableById(@Param("id") Long id);
|
GenTable selectGenTableById (Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询表名称业务信息
|
* 查询表名称业务信息
|
||||||
*
|
*
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
|
*
|
||||||
* @return 业务信息
|
* @return 业务信息
|
||||||
*/
|
*/
|
||||||
public GenTable selectGenTableByName(@Param("tableName") String tableName);
|
GenTable selectGenTableByName (String tableName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增业务
|
* 新增业务
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertGenTable(GenTable genTable);
|
int insertGenTable (GenTable genTable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改业务
|
* 修改业务
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int updateGenTable(GenTable genTable);
|
int updateGenTable (GenTable genTable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除业务
|
* 批量删除业务
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的数据ID
|
* @param ids 需要删除的数据ID
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteGenTableByIds(@Param("ids") Long[] ids);
|
int deleteGenTableByIds (Long[] ids);
|
||||||
|
|
||||||
List<String> selDbNameAll();
|
|
||||||
|
|
||||||
List<GenTableResp> selectDbTableListAll();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.muyu.gen.service;
|
||||||
import com.muyu.common.core.text.Convert;
|
import com.muyu.common.core.text.Convert;
|
||||||
import com.muyu.gen.domain.GenTableColumn;
|
import com.muyu.gen.domain.GenTableColumn;
|
||||||
import com.muyu.gen.mapper.GenTableColumnMapper;
|
import com.muyu.gen.mapper.GenTableColumnMapper;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -11,64 +11,58 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* 业务字段 服务层实现
|
* 业务字段 服务层实现
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class GenTableColumnServiceImpl implements IGenTableColumnService
|
public class GenTableColumnServiceImpl implements IGenTableColumnService {
|
||||||
{
|
@Autowired
|
||||||
@Resource
|
private GenTableColumnMapper genTableColumnMapper;
|
||||||
private GenTableColumnMapper genTableColumnMapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询业务字段列表
|
* 查询业务字段列表
|
||||||
*
|
*
|
||||||
* @param tableId 业务字段编号
|
* @param tableId 业务字段编号
|
||||||
|
*
|
||||||
* @return 业务字段集合
|
* @return 业务字段集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId)
|
public List<GenTableColumn> selectGenTableColumnListByTableId (Long tableId) {
|
||||||
{
|
return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
|
||||||
return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增业务字段
|
* 新增业务字段
|
||||||
*
|
*
|
||||||
* @param genTableColumn 业务字段信息
|
* @param genTableColumn 业务字段信息
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertGenTableColumn(GenTableColumn genTableColumn)
|
public int insertGenTableColumn (GenTableColumn genTableColumn) {
|
||||||
{
|
return genTableColumnMapper.insertGenTableColumn(genTableColumn);
|
||||||
return genTableColumnMapper.insertGenTableColumn(genTableColumn);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改业务字段
|
* 修改业务字段
|
||||||
*
|
*
|
||||||
* @param genTableColumn 业务字段信息
|
* @param genTableColumn 业务字段信息
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateGenTableColumn(GenTableColumn genTableColumn)
|
public int updateGenTableColumn (GenTableColumn genTableColumn) {
|
||||||
{
|
return genTableColumnMapper.updateGenTableColumn(genTableColumn);
|
||||||
return genTableColumnMapper.updateGenTableColumn(genTableColumn);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除业务字段对象
|
* 删除业务字段对象
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的数据ID
|
* @param ids 需要删除的数据ID
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public int deleteGenTableColumnByIds(String ids)
|
|
||||||
{
|
|
||||||
return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<GenTableColumn> selectDbTableColumnsByName(String table, String dbName) {
|
public int deleteGenTableColumnByIds (String ids) {
|
||||||
return genTableColumnMapper.selectDbTableColumnsByName(table,dbName);
|
return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.gen.domain.GenTable;
|
import com.muyu.gen.domain.GenTable;
|
||||||
import com.muyu.gen.domain.GenTableColumn;
|
import com.muyu.gen.domain.GenTableColumn;
|
||||||
import com.muyu.gen.domain.GenTableResp;
|
|
||||||
import com.muyu.gen.mapper.GenTableColumnMapper;
|
import com.muyu.gen.mapper.GenTableColumnMapper;
|
||||||
import com.muyu.gen.mapper.GenTableMapper;
|
import com.muyu.gen.mapper.GenTableMapper;
|
||||||
import com.muyu.gen.util.GenUtils;
|
import com.muyu.gen.util.GenUtils;
|
||||||
|
@ -23,7 +22,7 @@ import org.apache.velocity.VelocityContext;
|
||||||
import org.apache.velocity.app.Velocity;
|
import org.apache.velocity.app.Velocity;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@ -42,28 +41,43 @@ import java.util.zip.ZipOutputStream;
|
||||||
/**
|
/**
|
||||||
* 业务 服务层实现
|
* 业务 服务层实现
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class GenTableServiceImpl implements IGenTableService
|
public class GenTableServiceImpl implements IGenTableService {
|
||||||
{
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private GenTableMapper genTableMapper;
|
private GenTableMapper genTableMapper;
|
||||||
|
|
||||||
@Resource
|
@Autowired
|
||||||
private GenTableColumnMapper genTableColumnMapper;
|
private GenTableColumnMapper genTableColumnMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取代码生成地址
|
||||||
|
*
|
||||||
|
* @param table 业务表信息
|
||||||
|
* @param template 模板文件路径
|
||||||
|
*
|
||||||
|
* @return 生成地址
|
||||||
|
*/
|
||||||
|
public static String getGenPath (GenTable table, String template) {
|
||||||
|
String genPath = table.getGenPath();
|
||||||
|
if (StringUtils.equals(genPath, "/")) {
|
||||||
|
return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table);
|
||||||
|
}
|
||||||
|
return genPath + File.separator + VelocityUtils.getFileName(template, table);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询业务信息
|
* 查询业务信息
|
||||||
*
|
*
|
||||||
* @param id 业务ID
|
* @param id 业务ID
|
||||||
|
*
|
||||||
* @return 业务信息
|
* @return 业务信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public GenTable selectGenTableById(Long id)
|
public GenTable selectGenTableById (Long id) {
|
||||||
{
|
|
||||||
GenTable genTable = genTableMapper.selectGenTableById(id);
|
GenTable genTable = genTableMapper.selectGenTableById(id);
|
||||||
setTableFromOptions(genTable);
|
setTableFromOptions(genTable);
|
||||||
return genTable;
|
return genTable;
|
||||||
|
@ -73,11 +87,11 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* 查询业务列表
|
* 查询业务列表
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
|
*
|
||||||
* @return 业务集合
|
* @return 业务集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<GenTable> selectGenTableList(GenTable genTable)
|
public List<GenTable> selectGenTableList (GenTable genTable) {
|
||||||
{
|
|
||||||
return genTableMapper.selectGenTableList(genTable);
|
return genTableMapper.selectGenTableList(genTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,11 +99,11 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* 查询据库列表
|
* 查询据库列表
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
|
*
|
||||||
* @return 数据库表集合
|
* @return 数据库表集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<GenTable> selectDbTableList(GenTable genTable)
|
public List<GenTable> selectDbTableList (GenTable genTable) {
|
||||||
{
|
|
||||||
return genTableMapper.selectDbTableList(genTable);
|
return genTableMapper.selectDbTableList(genTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,13 +111,12 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* 查询据库列表
|
* 查询据库列表
|
||||||
*
|
*
|
||||||
* @param tableNames 表名称组
|
* @param tableNames 表名称组
|
||||||
* @param dbName
|
*
|
||||||
* @return 数据库表集合
|
* @return 数据库表集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<GenTable> selectDbTableListByNames(String[] tableNames, String dbName)
|
public List<GenTable> selectDbTableListByNames (String[] tableNames) {
|
||||||
{
|
return genTableMapper.selectDbTableListByNames(tableNames);
|
||||||
return genTableMapper.selectDbTableListByNames(tableNames,dbName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,8 +125,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* @return 表信息集合
|
* @return 表信息集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<GenTable> selectGenTableAll()
|
public List<GenTable> selectGenTableAll () {
|
||||||
{
|
|
||||||
return genTableMapper.selectGenTableAll();
|
return genTableMapper.selectGenTableAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,19 +133,17 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* 修改业务
|
* 修改业务
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void updateGenTable(GenTable genTable)
|
public void updateGenTable (GenTable genTable) {
|
||||||
{
|
|
||||||
String options = JSON.toJSONString(genTable.getParams());
|
String options = JSON.toJSONString(genTable.getParams());
|
||||||
genTable.setOptions(options);
|
genTable.setOptions(options);
|
||||||
int row = genTableMapper.updateGenTable(genTable);
|
int row = genTableMapper.updateGenTable(genTable);
|
||||||
if (row > 0)
|
if (row > 0) {
|
||||||
{
|
for (GenTableColumn cenTableColumn : genTable.getColumns()) {
|
||||||
for (GenTableColumn cenTableColumn : genTable.getColumns())
|
|
||||||
{
|
|
||||||
genTableColumnMapper.updateGenTableColumn(cenTableColumn);
|
genTableColumnMapper.updateGenTableColumn(cenTableColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,12 +153,12 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* 删除业务对象
|
* 删除业务对象
|
||||||
*
|
*
|
||||||
* @param tableIds 需要删除的数据ID
|
* @param tableIds 需要删除的数据ID
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteGenTableByIds(Long[] tableIds)
|
public void deleteGenTableByIds (Long[] tableIds) {
|
||||||
{
|
|
||||||
genTableMapper.deleteGenTableByIds(tableIds);
|
genTableMapper.deleteGenTableByIds(tableIds);
|
||||||
genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
|
genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
|
||||||
}
|
}
|
||||||
|
@ -160,31 +170,23 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void importGenTable(List<GenTable> tableList)
|
public void importGenTable (List<GenTable> tableList) {
|
||||||
{
|
|
||||||
String operName = SecurityUtils.getUsername();
|
String operName = SecurityUtils.getUsername();
|
||||||
try
|
try {
|
||||||
{
|
for (GenTable table : tableList) {
|
||||||
for (GenTable table : tableList)
|
|
||||||
{
|
|
||||||
String dbName = table.getDbName();
|
|
||||||
String tableName = table.getTableName();
|
String tableName = table.getTableName();
|
||||||
GenUtils.initTable(table, operName);
|
GenUtils.initTable(table, operName);
|
||||||
int row = genTableMapper.insertGenTable(table);
|
int row = genTableMapper.insertGenTable(table);
|
||||||
if (row > 0)
|
if (row > 0) {
|
||||||
{
|
|
||||||
// 保存列信息
|
// 保存列信息
|
||||||
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName, dbName);
|
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
||||||
for (GenTableColumn column : genTableColumns)
|
for (GenTableColumn column : genTableColumns) {
|
||||||
{
|
|
||||||
GenUtils.initColumnField(column, table);
|
GenUtils.initColumnField(column, table);
|
||||||
genTableColumnMapper.insertGenTableColumn(column);
|
genTableColumnMapper.insertGenTableColumn(column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new ServiceException("导入失败:" + e.getMessage());
|
throw new ServiceException("导入失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,11 +195,11 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* 预览代码
|
* 预览代码
|
||||||
*
|
*
|
||||||
* @param tableId 表编号
|
* @param tableId 表编号
|
||||||
|
*
|
||||||
* @return 预览数据列表
|
* @return 预览数据列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> previewCode(Long tableId)
|
public Map<String, String> previewCode (Long tableId) {
|
||||||
{
|
|
||||||
Map<String, String> dataMap = new LinkedHashMap<>();
|
Map<String, String> dataMap = new LinkedHashMap<>();
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
GenTable table = genTableMapper.selectGenTableById(tableId);
|
GenTable table = genTableMapper.selectGenTableById(tableId);
|
||||||
|
@ -211,8 +213,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
|
|
||||||
// 获取模板列表
|
// 获取模板列表
|
||||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||||
for (String template : templates)
|
for (String template : templates) {
|
||||||
{
|
|
||||||
// 渲染模板
|
// 渲染模板
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
||||||
|
@ -226,11 +227,11 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* 生成代码(下载方式)
|
* 生成代码(下载方式)
|
||||||
*
|
*
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
|
*
|
||||||
* @return 数据
|
* @return 数据
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public byte[] downloadCode(String tableName)
|
public byte[] downloadCode (String tableName) {
|
||||||
{
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
||||||
generatorCode(tableName, zip);
|
generatorCode(tableName, zip);
|
||||||
|
@ -244,8 +245,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void generatorCode(String tableName)
|
public void generatorCode (String tableName) {
|
||||||
{
|
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
||||||
// 设置主子表信息
|
// 设置主子表信息
|
||||||
|
@ -259,21 +259,16 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
|
|
||||||
// 获取模板列表
|
// 获取模板列表
|
||||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||||
for (String template : templates)
|
for (String template : templates) {
|
||||||
{
|
if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) {
|
||||||
if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm"))
|
|
||||||
{
|
|
||||||
// 渲染模板
|
// 渲染模板
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
||||||
tpl.merge(context, sw);
|
tpl.merge(context, sw);
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
String path = getGenPath(table, template);
|
String path = getGenPath(table, template);
|
||||||
FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8);
|
FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8);
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
throw new ServiceException("渲染模板失败,表名:" + table.getTableName());
|
throw new ServiceException("渲染模板失败,表名:" + table.getTableName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,54 +279,45 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* 同步数据库
|
* 同步数据库
|
||||||
*
|
*
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
* @param dbName
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void synchDb(String tableName, String dbName)
|
public void synchDb (String tableName) {
|
||||||
{
|
|
||||||
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
||||||
List<GenTableColumn> tableColumns = table.getColumns();
|
List<GenTableColumn> tableColumns = table.getColumns();
|
||||||
Map<String, GenTableColumn> tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity()));
|
Map<String, GenTableColumn> tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity()));
|
||||||
|
|
||||||
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName, dbName);
|
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
||||||
if (StringUtils.isEmpty(dbTableColumns))
|
if (StringUtils.isEmpty(dbTableColumns)) {
|
||||||
{
|
|
||||||
throw new ServiceException("同步数据失败,原表结构不存在");
|
throw new ServiceException("同步数据失败,原表结构不存在");
|
||||||
}
|
}
|
||||||
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
||||||
|
|
||||||
dbTableColumns.forEach(column -> {
|
dbTableColumns.forEach(column -> {
|
||||||
GenUtils.initColumnField(column, table);
|
GenUtils.initColumnField(column, table);
|
||||||
if (tableColumnMap.containsKey(column.getColumnName()))
|
if (tableColumnMap.containsKey(column.getColumnName())) {
|
||||||
{
|
|
||||||
GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName());
|
GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName());
|
||||||
column.setColumnId(prevColumn.getColumnId());
|
column.setColumnId(prevColumn.getColumnId());
|
||||||
if (column.isList())
|
if (column.isList()) {
|
||||||
{
|
|
||||||
// 如果是列表,继续保留查询方式/字典类型选项
|
// 如果是列表,继续保留查询方式/字典类型选项
|
||||||
column.setDictType(prevColumn.getDictType());
|
column.setDictType(prevColumn.getDictType());
|
||||||
column.setQueryType(prevColumn.getQueryType());
|
column.setQueryType(prevColumn.getQueryType());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk()
|
if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk()
|
||||||
&& (column.isInsert() || column.isEdit())
|
&& (column.isInsert() || column.isEdit())
|
||||||
&& ((column.isUsableColumn()) || (!column.isSuperColumn())))
|
&& ((column.isUsableColumn()) || (!column.isSuperColumn()))) {
|
||||||
{
|
|
||||||
// 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项
|
// 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项
|
||||||
column.setIsRequired(prevColumn.getIsRequired());
|
column.setIsRequired(prevColumn.getIsRequired());
|
||||||
column.setHtmlType(prevColumn.getHtmlType());
|
column.setHtmlType(prevColumn.getHtmlType());
|
||||||
}
|
}
|
||||||
genTableColumnMapper.updateGenTableColumn(column);
|
genTableColumnMapper.updateGenTableColumn(column);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
genTableColumnMapper.insertGenTableColumn(column);
|
genTableColumnMapper.insertGenTableColumn(column);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
|
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
|
||||||
if (StringUtils.isNotEmpty(delColumns))
|
if (StringUtils.isNotEmpty(delColumns)) {
|
||||||
{
|
|
||||||
genTableColumnMapper.deleteGenTableColumns(delColumns);
|
genTableColumnMapper.deleteGenTableColumns(delColumns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -340,15 +326,14 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* 批量生成代码(下载方式)
|
* 批量生成代码(下载方式)
|
||||||
*
|
*
|
||||||
* @param tableNames 表数组
|
* @param tableNames 表数组
|
||||||
|
*
|
||||||
* @return 数据
|
* @return 数据
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public byte[] downloadCode(String[] tableNames)
|
public byte[] downloadCode (String[] tableNames) {
|
||||||
{
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
||||||
for (String tableName : tableNames)
|
for (String tableName : tableNames) {
|
||||||
{
|
|
||||||
generatorCode(tableName, zip);
|
generatorCode(tableName, zip);
|
||||||
}
|
}
|
||||||
IOUtils.closeQuietly(zip);
|
IOUtils.closeQuietly(zip);
|
||||||
|
@ -358,8 +343,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
/**
|
/**
|
||||||
* 查询表信息并生成代码
|
* 查询表信息并生成代码
|
||||||
*/
|
*/
|
||||||
private void generatorCode(String tableName, ZipOutputStream zip)
|
private void generatorCode (String tableName, ZipOutputStream zip) {
|
||||||
{
|
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
||||||
// 设置主子表信息
|
// 设置主子表信息
|
||||||
|
@ -373,23 +357,19 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
|
|
||||||
// 获取模板列表
|
// 获取模板列表
|
||||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||||
for (String template : templates)
|
for (String template : templates) {
|
||||||
{
|
|
||||||
// 渲染模板
|
// 渲染模板
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
||||||
tpl.merge(context, sw);
|
tpl.merge(context, sw);
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
// 添加到zip
|
// 添加到zip
|
||||||
zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
|
zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
|
||||||
IOUtils.write(sw.toString(), zip, Constants.UTF8);
|
IOUtils.write(sw.toString(), zip, Constants.UTF8);
|
||||||
IOUtils.closeQuietly(sw);
|
IOUtils.closeQuietly(sw);
|
||||||
zip.flush();
|
zip.flush();
|
||||||
zip.closeEntry();
|
zip.closeEntry();
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
log.error("渲染模板失败,表名:" + table.getTableName(), e);
|
log.error("渲染模板失败,表名:" + table.getTableName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -401,80 +381,49 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void validateEdit(GenTable genTable)
|
public void validateEdit (GenTable genTable) {
|
||||||
{
|
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
|
||||||
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory()))
|
|
||||||
{
|
|
||||||
String options = JSON.toJSONString(genTable.getParams());
|
String options = JSON.toJSONString(genTable.getParams());
|
||||||
JSONObject paramsObj = JSON.parseObject(options);
|
JSONObject paramsObj = JSON.parseObject(options);
|
||||||
if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE)))
|
if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) {
|
||||||
{
|
|
||||||
throw new ServiceException("树编码字段不能为空");
|
throw new ServiceException("树编码字段不能为空");
|
||||||
}
|
} else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) {
|
||||||
else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE)))
|
|
||||||
{
|
|
||||||
throw new ServiceException("树父编码字段不能为空");
|
throw new ServiceException("树父编码字段不能为空");
|
||||||
}
|
} else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) {
|
||||||
else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME)))
|
|
||||||
{
|
|
||||||
throw new ServiceException("树名称字段不能为空");
|
throw new ServiceException("树名称字段不能为空");
|
||||||
}
|
} else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) {
|
||||||
else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory()))
|
if (StringUtils.isEmpty(genTable.getSubTableName())) {
|
||||||
{
|
|
||||||
if (StringUtils.isEmpty(genTable.getSubTableName()))
|
|
||||||
{
|
|
||||||
throw new ServiceException("关联子表的表名不能为空");
|
throw new ServiceException("关联子表的表名不能为空");
|
||||||
}
|
} else if (StringUtils.isEmpty(genTable.getSubTableFkName())) {
|
||||||
else if (StringUtils.isEmpty(genTable.getSubTableFkName()))
|
|
||||||
{
|
|
||||||
throw new ServiceException("子表关联的外键名不能为空");
|
throw new ServiceException("子表关联的外键名不能为空");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> selDbNameAll() {
|
|
||||||
return genTableMapper.selDbNameAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<GenTableResp> selectDbTableListAll() {
|
|
||||||
return genTableMapper.selectDbTableListAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置主键列信息
|
* 设置主键列信息
|
||||||
*
|
*
|
||||||
* @param table 业务表信息
|
* @param table 业务表信息
|
||||||
*/
|
*/
|
||||||
public void setPkColumn(GenTable table)
|
public void setPkColumn (GenTable table) {
|
||||||
{
|
for (GenTableColumn column : table.getColumns()) {
|
||||||
for (GenTableColumn column : table.getColumns())
|
if (column.isPk()) {
|
||||||
{
|
|
||||||
if (column.isPk())
|
|
||||||
{
|
|
||||||
table.setPkColumn(column);
|
table.setPkColumn(column);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNull(table.getPkColumn()))
|
if (StringUtils.isNull(table.getPkColumn())) {
|
||||||
{
|
|
||||||
table.setPkColumn(table.getColumns().get(0));
|
table.setPkColumn(table.getColumns().get(0));
|
||||||
}
|
}
|
||||||
if (GenConstants.TPL_SUB.equals(table.getTplCategory()))
|
if (GenConstants.TPL_SUB.equals(table.getTplCategory())) {
|
||||||
{
|
for (GenTableColumn column : table.getSubTable().getColumns()) {
|
||||||
for (GenTableColumn column : table.getSubTable().getColumns())
|
if (column.isPk()) {
|
||||||
{
|
|
||||||
if (column.isPk())
|
|
||||||
{
|
|
||||||
table.getSubTable().setPkColumn(column);
|
table.getSubTable().setPkColumn(column);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNull(table.getSubTable().getPkColumn()))
|
if (StringUtils.isNull(table.getSubTable().getPkColumn())) {
|
||||||
{
|
|
||||||
table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
|
table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -485,11 +434,9 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
*
|
*
|
||||||
* @param table 业务表信息
|
* @param table 业务表信息
|
||||||
*/
|
*/
|
||||||
public void setSubTable(GenTable table)
|
public void setSubTable (GenTable table) {
|
||||||
{
|
|
||||||
String subTableName = table.getSubTableName();
|
String subTableName = table.getSubTableName();
|
||||||
if (StringUtils.isNotEmpty(subTableName))
|
if (StringUtils.isNotEmpty(subTableName)) {
|
||||||
{
|
|
||||||
table.setSubTable(genTableMapper.selectGenTableByName(subTableName));
|
table.setSubTable(genTableMapper.selectGenTableByName(subTableName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -499,11 +446,9 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
*
|
*
|
||||||
* @param genTable 设置后的生成对象
|
* @param genTable 设置后的生成对象
|
||||||
*/
|
*/
|
||||||
public void setTableFromOptions(GenTable genTable)
|
public void setTableFromOptions (GenTable genTable) {
|
||||||
{
|
|
||||||
JSONObject paramsObj = JSON.parseObject(genTable.getOptions());
|
JSONObject paramsObj = JSON.parseObject(genTable.getOptions());
|
||||||
if (StringUtils.isNotNull(paramsObj))
|
if (StringUtils.isNotNull(paramsObj)) {
|
||||||
{
|
|
||||||
String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
|
String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
|
||||||
String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
|
String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
|
||||||
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
||||||
|
@ -517,21 +462,4 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
genTable.setParentMenuName(parentMenuName);
|
genTable.setParentMenuName(parentMenuName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取代码生成地址
|
|
||||||
*
|
|
||||||
* @param table 业务表信息
|
|
||||||
* @param template 模板文件路径
|
|
||||||
* @return 生成地址
|
|
||||||
*/
|
|
||||||
public static String getGenPath(GenTable table, String template)
|
|
||||||
{
|
|
||||||
String genPath = table.getGenPath();
|
|
||||||
if (StringUtils.equals(genPath, "/"))
|
|
||||||
{
|
|
||||||
return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table);
|
|
||||||
}
|
|
||||||
return genPath + File.separator + VelocityUtils.getFileName(template, table);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,41 +7,42 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* 业务字段 服务层
|
* 业务字段 服务层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
public interface IGenTableColumnService
|
public interface IGenTableColumnService {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 查询业务字段列表
|
* 查询业务字段列表
|
||||||
*
|
*
|
||||||
* @param tableId 业务字段编号
|
* @param tableId 业务字段编号
|
||||||
|
*
|
||||||
* @return 业务字段集合
|
* @return 业务字段集合
|
||||||
*/
|
*/
|
||||||
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
|
List<GenTableColumn> selectGenTableColumnListByTableId (Long tableId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增业务字段
|
* 新增业务字段
|
||||||
*
|
*
|
||||||
* @param genTableColumn 业务字段信息
|
* @param genTableColumn 业务字段信息
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int insertGenTableColumn(GenTableColumn genTableColumn);
|
int insertGenTableColumn (GenTableColumn genTableColumn);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改业务字段
|
* 修改业务字段
|
||||||
*
|
*
|
||||||
* @param genTableColumn 业务字段信息
|
* @param genTableColumn 业务字段信息
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int updateGenTableColumn(GenTableColumn genTableColumn);
|
int updateGenTableColumn (GenTableColumn genTableColumn);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除业务字段信息
|
* 删除业务字段信息
|
||||||
*
|
*
|
||||||
* @param ids 需要删除的数据ID
|
* @param ids 需要删除的数据ID
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int deleteGenTableColumnByIds(String ids);
|
int deleteGenTableColumnByIds (String ids);
|
||||||
|
|
||||||
List<GenTableColumn> selectDbTableColumnsByName(String table, String dbName);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.muyu.gen.service;
|
package com.muyu.gen.service;
|
||||||
|
|
||||||
import com.muyu.gen.domain.GenTable;
|
import com.muyu.gen.domain.GenTable;
|
||||||
import com.muyu.gen.domain.GenTableResp;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -9,121 +8,124 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* 业务 服务层
|
* 业务 服务层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
public interface IGenTableService
|
public interface IGenTableService {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 查询业务列表
|
* 查询业务列表
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
|
*
|
||||||
* @return 业务集合
|
* @return 业务集合
|
||||||
*/
|
*/
|
||||||
public List<GenTable> selectGenTableList(GenTable genTable);
|
List<GenTable> selectGenTableList (GenTable genTable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询据库列表
|
* 查询据库列表
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
|
*
|
||||||
* @return 数据库表集合
|
* @return 数据库表集合
|
||||||
*/
|
*/
|
||||||
public List<GenTable> selectDbTableList(GenTable genTable);
|
List<GenTable> selectDbTableList (GenTable genTable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询据库列表
|
* 查询据库列表
|
||||||
*
|
*
|
||||||
* @param tableNames 表名称组
|
* @param tableNames 表名称组
|
||||||
* @param dbName
|
*
|
||||||
* @return 数据库表集合
|
* @return 数据库表集合
|
||||||
*/
|
*/
|
||||||
public List<GenTable> selectDbTableListByNames(String[] tableNames, String dbName);
|
List<GenTable> selectDbTableListByNames (String[] tableNames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询所有表信息
|
* 查询所有表信息
|
||||||
*
|
*
|
||||||
* @return 表信息集合
|
* @return 表信息集合
|
||||||
*/
|
*/
|
||||||
public List<GenTable> selectGenTableAll();
|
List<GenTable> selectGenTableAll ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询业务信息
|
* 查询业务信息
|
||||||
*
|
*
|
||||||
* @param id 业务ID
|
* @param id 业务ID
|
||||||
|
*
|
||||||
* @return 业务信息
|
* @return 业务信息
|
||||||
*/
|
*/
|
||||||
public GenTable selectGenTableById(Long id);
|
GenTable selectGenTableById (Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改业务
|
* 修改业务
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public void updateGenTable(GenTable genTable);
|
void updateGenTable (GenTable genTable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除业务信息
|
* 删除业务信息
|
||||||
*
|
*
|
||||||
* @param tableIds 需要删除的表数据ID
|
* @param tableIds 需要删除的表数据ID
|
||||||
|
*
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public void deleteGenTableByIds(Long[] tableIds);
|
void deleteGenTableByIds (Long[] tableIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导入表结构
|
* 导入表结构
|
||||||
*
|
*
|
||||||
* @param tableList 导入表列表
|
* @param tableList 导入表列表
|
||||||
*/
|
*/
|
||||||
public void importGenTable(List<GenTable> tableList);
|
void importGenTable (List<GenTable> tableList);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预览代码
|
* 预览代码
|
||||||
*
|
*
|
||||||
* @param tableId 表编号
|
* @param tableId 表编号
|
||||||
|
*
|
||||||
* @return 预览数据列表
|
* @return 预览数据列表
|
||||||
*/
|
*/
|
||||||
public Map<String, String> previewCode(Long tableId);
|
Map<String, String> previewCode (Long tableId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成代码(下载方式)
|
* 生成代码(下载方式)
|
||||||
*
|
*
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
|
*
|
||||||
* @return 数据
|
* @return 数据
|
||||||
*/
|
*/
|
||||||
public byte[] downloadCode(String tableName);
|
byte[] downloadCode (String tableName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成代码(自定义路径)
|
* 生成代码(自定义路径)
|
||||||
*
|
*
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
|
*
|
||||||
* @return 数据
|
* @return 数据
|
||||||
*/
|
*/
|
||||||
public void generatorCode(String tableName);
|
void generatorCode (String tableName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步数据库
|
* 同步数据库
|
||||||
*
|
*
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
* @param dbName
|
|
||||||
*/
|
*/
|
||||||
public void synchDb(String tableName, String dbName);
|
void synchDb (String tableName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量生成代码(下载方式)
|
* 批量生成代码(下载方式)
|
||||||
*
|
*
|
||||||
* @param tableNames 表数组
|
* @param tableNames 表数组
|
||||||
|
*
|
||||||
* @return 数据
|
* @return 数据
|
||||||
*/
|
*/
|
||||||
public byte[] downloadCode(String[] tableNames);
|
byte[] downloadCode (String[] tableNames);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改保存参数校验
|
* 修改保存参数校验
|
||||||
*
|
*
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
*/
|
*/
|
||||||
public void validateEdit(GenTable genTable);
|
void validateEdit (GenTable genTable);
|
||||||
|
|
||||||
List<String> selDbNameAll();
|
|
||||||
|
|
||||||
List<GenTableResp> selectDbTableListAll();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
# Tomcat
|
# Tomcat
|
||||||
server:
|
server:
|
||||||
port: 9709
|
port: 9202
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
nacos:
|
nacos:
|
||||||
addr: 110.42.213.184:8848
|
addr: nacos.muyu.icu:8848
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: icecream
|
namespace: muyu-cloud
|
||||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
amqp:
|
|
||||||
deserialization:
|
|
||||||
trust:
|
|
||||||
all: true
|
|
||||||
main:
|
main:
|
||||||
allow-bean-definition-overriding: true
|
allow-bean-definition-overriding: true
|
||||||
application:
|
application:
|
||||||
|
@ -29,18 +25,18 @@ spring:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: ${nacos.addr}
|
server-addr: ${nacos.addr}
|
||||||
# nacos用户名
|
# nacos用户名
|
||||||
# username: ${nacos.user-name}
|
username: ${nacos.user-name}
|
||||||
# # nacos密码
|
# nacos密码
|
||||||
# password: ${nacos.password}
|
password: ${nacos.password}
|
||||||
# 命名空间
|
# 命名空间
|
||||||
namespace: ${nacos.namespace}
|
namespace: ${nacos.namespace}
|
||||||
config:
|
config:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: ${nacos.addr}
|
server-addr: ${nacos.addr}
|
||||||
# nacos用户名
|
# nacos用户名
|
||||||
# username: ${nacos.user-name}
|
username: ${nacos.user-name}
|
||||||
# # nacos密码
|
# nacos密码
|
||||||
# password: ${nacos.password}
|
password: ${nacos.password}
|
||||||
# 命名空间
|
# 命名空间
|
||||||
namespace: ${nacos.namespace}
|
namespace: ${nacos.namespace}
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
|
@ -53,8 +49,3 @@ spring:
|
||||||
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
# xxl-job 配置文件
|
# xxl-job 配置文件
|
||||||
- application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
# rabbit 配置文件
|
|
||||||
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
|
||||||
logging:
|
|
||||||
level:
|
|
||||||
com.muyu.system.mapper: DEBUG
|
|
||||||
|
|
|
@ -1,36 +1,58 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper
|
<!DOCTYPE mapper
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.muyu.gen.mapper.GenTableColumnMapper">
|
<mapper namespace="com.muyu.gen.mapper.GenTableColumnMapper">
|
||||||
|
|
||||||
<resultMap type="com.muyu.gen.domain.GenTableColumn" id="GenTableColumnResult">
|
<resultMap type="com.muyu.gen.domain.GenTableColumn" id="GenTableColumnResult">
|
||||||
<id property="columnId" column="column_id" />
|
<id property="columnId" column="column_id"/>
|
||||||
<result property="tableId" column="table_id" />
|
<result property="tableId" column="table_id"/>
|
||||||
<result property="columnName" column="column_name" />
|
<result property="columnName" column="column_name"/>
|
||||||
<result property="columnComment" column="column_comment" />
|
<result property="columnComment" column="column_comment"/>
|
||||||
<result property="columnType" column="column_type" />
|
<result property="columnType" column="column_type"/>
|
||||||
<result property="javaType" column="java_type" />
|
<result property="javaType" column="java_type"/>
|
||||||
<result property="javaField" column="java_field" />
|
<result property="javaField" column="java_field"/>
|
||||||
<result property="isPk" column="is_pk" />
|
<result property="isPk" column="is_pk"/>
|
||||||
<result property="isIncrement" column="is_increment" />
|
<result property="isIncrement" column="is_increment"/>
|
||||||
<result property="isRequired" column="is_required" />
|
<result property="isRequired" column="is_required"/>
|
||||||
<result property="isInsert" column="is_insert" />
|
<result property="isInsert" column="is_insert"/>
|
||||||
<result property="isEdit" column="is_edit" />
|
<result property="isEdit" column="is_edit"/>
|
||||||
<result property="isList" column="is_list" />
|
<result property="isList" column="is_list"/>
|
||||||
<result property="isQuery" column="is_query" />
|
<result property="isQuery" column="is_query"/>
|
||||||
<result property="queryType" column="query_type" />
|
<result property="queryType" column="query_type"/>
|
||||||
<result property="htmlType" column="html_type" />
|
<result property="htmlType" column="html_type"/>
|
||||||
<result property="dictType" column="dict_type" />
|
<result property="dictType" column="dict_type"/>
|
||||||
<result property="sort" column="sort" />
|
<result property="sort" column="sort"/>
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by"/>
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time"/>
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by"/>
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectGenTableColumnVo">
|
<sql id="selectGenTableColumnVo">
|
||||||
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
|
select column_id,
|
||||||
|
table_id,
|
||||||
|
column_name,
|
||||||
|
column_comment,
|
||||||
|
column_type,
|
||||||
|
java_type,
|
||||||
|
java_field,
|
||||||
|
is_pk,
|
||||||
|
is_increment,
|
||||||
|
is_required,
|
||||||
|
is_insert,
|
||||||
|
is_edit,
|
||||||
|
is_list,
|
||||||
|
is_query,
|
||||||
|
query_type,
|
||||||
|
html_type,
|
||||||
|
dict_type,
|
||||||
|
sort,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time
|
||||||
|
from gen_table_column
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectGenTableColumnListByTableId" parameterType="com.muyu.gen.domain.GenTableColumn" resultMap="GenTableColumnResult">
|
<select id="selectGenTableColumnListByTableId" parameterType="com.muyu.gen.domain.GenTableColumn" resultMap="GenTableColumnResult">
|
||||||
|
@ -40,55 +62,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
|
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
|
||||||
select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type
|
select column_name,
|
||||||
from information_schema.columns where
|
(case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required,
|
||||||
<include refid="com.muyu.gen.mapper.GenTableMapper.select_dbName"/>
|
(case when column_key = 'PRI' then '1' else '0' end) as is_pk,
|
||||||
and table_name = (#{tableName})
|
ordinal_position as sort,
|
||||||
order by ordinal_position
|
column_comment,
|
||||||
</select>
|
(case when extra = 'auto_increment' then '1' else '0' end) as is_increment,
|
||||||
|
column_type
|
||||||
|
from information_schema.columns
|
||||||
|
where table_schema = (select database())
|
||||||
|
and table_name = (#{tableName})
|
||||||
|
order by ordinal_position
|
||||||
|
</select>
|
||||||
|
|
||||||
<insert id="insertGenTableColumn" parameterType="com.muyu.gen.domain.GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
|
<insert id="insertGenTableColumn" parameterType="com.muyu.gen.domain.GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
|
||||||
insert into gen_table_column (
|
insert into gen_table_column (
|
||||||
<if test="tableId != null and tableId != ''">table_id,</if>
|
<if test="tableId != null and tableId != ''">table_id,</if>
|
||||||
<if test="columnName != null and columnName != ''">column_name,</if>
|
<if test="columnName != null and columnName != ''">column_name,</if>
|
||||||
<if test="columnComment != null and columnComment != ''">column_comment,</if>
|
<if test="columnComment != null and columnComment != ''">column_comment,</if>
|
||||||
<if test="columnType != null and columnType != ''">column_type,</if>
|
<if test="columnType != null and columnType != ''">column_type,</if>
|
||||||
<if test="javaType != null and javaType != ''">java_type,</if>
|
<if test="javaType != null and javaType != ''">java_type,</if>
|
||||||
<if test="javaField != null and javaField != ''">java_field,</if>
|
<if test="javaField != null and javaField != ''">java_field,</if>
|
||||||
<if test="isPk != null and isPk != ''">is_pk,</if>
|
<if test="isPk != null and isPk != ''">is_pk,</if>
|
||||||
<if test="isIncrement != null and isIncrement != ''">is_increment,</if>
|
<if test="isIncrement != null and isIncrement != ''">is_increment,</if>
|
||||||
<if test="isRequired != null and isRequired != ''">is_required,</if>
|
<if test="isRequired != null and isRequired != ''">is_required,</if>
|
||||||
<if test="isInsert != null and isInsert != ''">is_insert,</if>
|
<if test="isInsert != null and isInsert != ''">is_insert,</if>
|
||||||
<if test="isEdit != null and isEdit != ''">is_edit,</if>
|
<if test="isEdit != null and isEdit != ''">is_edit,</if>
|
||||||
<if test="isList != null and isList != ''">is_list,</if>
|
<if test="isList != null and isList != ''">is_list,</if>
|
||||||
<if test="isQuery != null and isQuery != ''">is_query,</if>
|
<if test="isQuery != null and isQuery != ''">is_query,</if>
|
||||||
<if test="queryType != null and queryType != ''">query_type,</if>
|
<if test="queryType != null and queryType != ''">query_type,</if>
|
||||||
<if test="htmlType != null and htmlType != ''">html_type,</if>
|
<if test="htmlType != null and htmlType != ''">html_type,</if>
|
||||||
<if test="dictType != null and dictType != ''">dict_type,</if>
|
<if test="dictType != null and dictType != ''">dict_type,</if>
|
||||||
<if test="sort != null">sort,</if>
|
<if test="sort != null">sort,</if>
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
create_time
|
create_time
|
||||||
)values(
|
)values(
|
||||||
<if test="tableId != null and tableId != ''">#{tableId},</if>
|
<if test="tableId != null and tableId != ''">#{tableId},</if>
|
||||||
<if test="columnName != null and columnName != ''">#{columnName},</if>
|
<if test="columnName != null and columnName != ''">#{columnName},</if>
|
||||||
<if test="columnComment != null and columnComment != ''">#{columnComment},</if>
|
<if test="columnComment != null and columnComment != ''">#{columnComment},</if>
|
||||||
<if test="columnType != null and columnType != ''">#{columnType},</if>
|
<if test="columnType != null and columnType != ''">#{columnType},</if>
|
||||||
<if test="javaType != null and javaType != ''">#{javaType},</if>
|
<if test="javaType != null and javaType != ''">#{javaType},</if>
|
||||||
<if test="javaField != null and javaField != ''">#{javaField},</if>
|
<if test="javaField != null and javaField != ''">#{javaField},</if>
|
||||||
<if test="isPk != null and isPk != ''">#{isPk},</if>
|
<if test="isPk != null and isPk != ''">#{isPk},</if>
|
||||||
<if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
|
<if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
|
||||||
<if test="isRequired != null and isRequired != ''">#{isRequired},</if>
|
<if test="isRequired != null and isRequired != ''">#{isRequired},</if>
|
||||||
<if test="isInsert != null and isInsert != ''">#{isInsert},</if>
|
<if test="isInsert != null and isInsert != ''">#{isInsert},</if>
|
||||||
<if test="isEdit != null and isEdit != ''">#{isEdit},</if>
|
<if test="isEdit != null and isEdit != ''">#{isEdit},</if>
|
||||||
<if test="isList != null and isList != ''">#{isList},</if>
|
<if test="isList != null and isList != ''">#{isList},</if>
|
||||||
<if test="isQuery != null and isQuery != ''">#{isQuery},</if>
|
<if test="isQuery != null and isQuery != ''">#{isQuery},</if>
|
||||||
<if test="queryType != null and queryType != ''">#{queryType},</if>
|
<if test="queryType != null and queryType != ''">#{queryType},</if>
|
||||||
<if test="htmlType != null and htmlType != ''">#{htmlType},</if>
|
<if test="htmlType != null and htmlType != ''">#{htmlType},</if>
|
||||||
<if test="dictType != null and dictType != ''">#{dictType},</if>
|
<if test="dictType != null and dictType != ''">#{dictType},</if>
|
||||||
<if test="sort != null">#{sort},</if>
|
<if test="sort != null">#{sort},</if>
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
sysdate()
|
sysdate()
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateGenTableColumn" parameterType="com.muyu.gen.domain.GenTableColumn">
|
<update id="updateGenTableColumn" parameterType="com.muyu.gen.domain.GenTableColumn">
|
||||||
|
@ -113,20 +141,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteGenTableColumnByIds" parameterType="Long">
|
<delete id="deleteGenTableColumnByIds" parameterType="Long">
|
||||||
delete from gen_table_column where table_id in (
|
delete from gen_table_column where table_id in
|
||||||
<foreach collection="ids" item="tableId" separator="," >
|
<foreach collection="array" item="tableId" open="(" separator="," close=")">
|
||||||
#{tableId}
|
#{tableId}
|
||||||
</foreach>
|
</foreach>
|
||||||
)
|
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
<delete id="deleteGenTableColumns">
|
<delete id="deleteGenTableColumns">
|
||||||
delete from gen_table_column where column_id in (
|
delete from gen_table_column where column_id in
|
||||||
<foreach collection="genTableColumns" item="item" separator="," >
|
<foreach collection="list" item="item" open="(" separator="," close=")">
|
||||||
#{item.columnId}
|
#{item.columnId}
|
||||||
</foreach>
|
</foreach>
|
||||||
)
|
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -1,208 +1,291 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper
|
<!DOCTYPE mapper
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.muyu.gen.mapper.GenTableMapper">
|
<mapper namespace="com.muyu.gen.mapper.GenTableMapper">
|
||||||
|
|
||||||
<resultMap type="com.muyu.gen.domain.GenTable" id="GenTableResult">
|
<resultMap type="com.muyu.gen.domain.GenTable" id="GenTableResult">
|
||||||
<id property="tableId" column="table_id" />
|
<id property="tableId" column="table_id"/>
|
||||||
<result property="dbName" column="db_name" />
|
<result property="tableName" column="table_name"/>
|
||||||
<result property="tableName" column="table_name" />
|
<result property="tableComment" column="table_comment"/>
|
||||||
<result property="tableComment" column="table_comment" />
|
<result property="subTableName" column="sub_table_name"/>
|
||||||
<result property="subTableName" column="sub_table_name" />
|
<result property="subTableFkName" column="sub_table_fk_name"/>
|
||||||
<result property="subTableFkName" column="sub_table_fk_name" />
|
<result property="className" column="class_name"/>
|
||||||
<result property="className" column="class_name" />
|
<result property="tplCategory" column="tpl_category"/>
|
||||||
<result property="tplCategory" column="tpl_category" />
|
<result property="packageName" column="package_name"/>
|
||||||
<result property="packageName" column="package_name" />
|
<result property="moduleName" column="module_name"/>
|
||||||
<result property="moduleName" column="module_name" />
|
<result property="businessName" column="business_name"/>
|
||||||
<result property="businessName" column="business_name" />
|
<result property="functionName" column="function_name"/>
|
||||||
<result property="functionName" column="function_name" />
|
<result property="functionAuthor" column="function_author"/>
|
||||||
<result property="functionAuthor" column="function_author" />
|
<result property="genType" column="gen_type"/>
|
||||||
<result property="genType" column="gen_type" />
|
<result property="genPath" column="gen_path"/>
|
||||||
<result property="genPath" column="gen_path" />
|
<result property="options" column="options"/>
|
||||||
<result property="options" column="options" />
|
<result property="createBy" column="create_by"/>
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createTime" column="create_time"/>
|
||||||
<result property="createTime" column="create_time" />
|
<result property="updateBy" column="update_by"/>
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateTime" column="update_time"/>
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="remark" column="remark"/>
|
||||||
<result property="remark" column="remark" />
|
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult"/>
|
||||||
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<resultMap type="com.muyu.gen.domain.GenTableColumn" id="GenTableColumnResult">
|
|
||||||
<id property="columnId" column="column_id" />
|
|
||||||
<result property="tableId" column="table_id" />
|
|
||||||
<result property="columnName" column="column_name" />
|
|
||||||
<result property="columnComment" column="column_comment" />
|
|
||||||
<result property="columnType" column="column_type" />
|
|
||||||
<result property="javaType" column="java_type" />
|
|
||||||
<result property="javaField" column="java_field" />
|
|
||||||
<result property="isPk" column="is_pk" />
|
|
||||||
<result property="isIncrement" column="is_increment" />
|
|
||||||
<result property="isRequired" column="is_required" />
|
|
||||||
<result property="isInsert" column="is_insert" />
|
|
||||||
<result property="isEdit" column="is_edit" />
|
|
||||||
<result property="isList" column="is_list" />
|
|
||||||
<result property="isQuery" column="is_query" />
|
|
||||||
<result property="queryType" column="query_type" />
|
|
||||||
<result property="htmlType" column="html_type" />
|
|
||||||
<result property="dictType" column="dict_type" />
|
|
||||||
<result property="sort" column="sort" />
|
|
||||||
<result property="createBy" column="create_by" />
|
|
||||||
<result property="createTime" column="create_time" />
|
|
||||||
<result property="updateBy" column="update_by" />
|
|
||||||
<result property="updateTime" column="update_time" />
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectGenTableVo">
|
<resultMap type="com.muyu.gen.domain.GenTableColumn" id="GenTableColumnResult">
|
||||||
select table_id, db_name, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
|
<id property="columnId" column="column_id"/>
|
||||||
|
<result property="tableId" column="table_id"/>
|
||||||
|
<result property="columnName" column="column_name"/>
|
||||||
|
<result property="columnComment" column="column_comment"/>
|
||||||
|
<result property="columnType" column="column_type"/>
|
||||||
|
<result property="javaType" column="java_type"/>
|
||||||
|
<result property="javaField" column="java_field"/>
|
||||||
|
<result property="isPk" column="is_pk"/>
|
||||||
|
<result property="isIncrement" column="is_increment"/>
|
||||||
|
<result property="isRequired" column="is_required"/>
|
||||||
|
<result property="isInsert" column="is_insert"/>
|
||||||
|
<result property="isEdit" column="is_edit"/>
|
||||||
|
<result property="isList" column="is_list"/>
|
||||||
|
<result property="isQuery" column="is_query"/>
|
||||||
|
<result property="queryType" column="query_type"/>
|
||||||
|
<result property="htmlType" column="html_type"/>
|
||||||
|
<result property="dictType" column="dict_type"/>
|
||||||
|
<result property="sort" column="sort"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectGenTableVo">
|
||||||
|
select table_id,
|
||||||
|
table_name,
|
||||||
|
table_comment,
|
||||||
|
sub_table_name,
|
||||||
|
sub_table_fk_name,
|
||||||
|
class_name,
|
||||||
|
tpl_category,
|
||||||
|
package_name,
|
||||||
|
module_name,
|
||||||
|
business_name,
|
||||||
|
function_name,
|
||||||
|
function_author,
|
||||||
|
gen_type,
|
||||||
|
gen_path,
|
||||||
|
options,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time,
|
||||||
|
remark
|
||||||
|
from gen_table
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="select_dbName">
|
|
||||||
<choose>
|
|
||||||
<when test="dbName!=null and dbName!=''">
|
|
||||||
table_schema in (#{dbName})
|
|
||||||
</when>
|
|
||||||
<otherwise>
|
|
||||||
table_schema = (select database())
|
|
||||||
</otherwise>
|
|
||||||
</choose>
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="selectGenTableList" parameterType="com.muyu.gen.domain.GenTable" resultMap="GenTableResult">
|
<select id="selectGenTableList" parameterType="com.muyu.gen.domain.GenTable" resultMap="GenTableResult">
|
||||||
<include refid="selectGenTableVo"/>
|
<include refid="selectGenTableVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="tableName != null and tableName != ''">
|
<if test="tableName != null and tableName != ''">
|
||||||
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
|
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
|
||||||
</if>
|
</if>
|
||||||
<if test="tableComment != null and tableComment != ''">
|
<if test="tableComment != null and tableComment != ''">
|
||||||
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
||||||
</if>
|
</if>
|
||||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||||
AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDbTableList" parameterType="com.muyu.gen.domain.GenTable" resultMap="GenTableResult">
|
<select id="selectDbTableList" parameterType="com.muyu.gen.domain.GenTable" resultMap="GenTableResult">
|
||||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||||
where
|
where table_schema = (select database())
|
||||||
<include refid="select_dbName"/>
|
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
|
||||||
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
|
AND table_name NOT IN (select table_name from gen_table)
|
||||||
AND table_name NOT IN (select table_name from gen_table)
|
<if test="tableName != null and tableName != ''">
|
||||||
<if test="tableName != null and tableName != ''">
|
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
|
||||||
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
|
</if>
|
||||||
</if>
|
<if test="tableComment != null and tableComment != ''">
|
||||||
<if test="tableComment != null and tableComment != ''">
|
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
||||||
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
</if>
|
||||||
</if>
|
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
||||||
AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
</if>
|
||||||
</if>
|
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
||||||
AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
</if>
|
||||||
</if>
|
|
||||||
order by create_time desc
|
order by create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDbTableListByNames" resultMap="GenTableResult">
|
<select id="selectDbTableListByNames" resultMap="GenTableResult">
|
||||||
select table_name, table_schema db_name, table_comment, create_time, update_time from information_schema.tables
|
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||||
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%'
|
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
|
||||||
and <include refid="select_dbName"/>
|
and table_name in
|
||||||
and table_name in
|
<foreach collection="array" item="name" open="(" separator="," close=")">
|
||||||
<foreach collection="tableNames" item="name" open="(" separator="," close=")">
|
#{name}
|
||||||
#{name}
|
|
||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
|
<select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
|
||||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
select table_name, table_comment, create_time, update_time
|
||||||
where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
|
from information_schema.tables
|
||||||
and table_name = #{tableName}
|
where table_comment <![CDATA[ <> ]]> ''
|
||||||
</select>
|
and table_schema = (select database())
|
||||||
|
and table_name = #{tableName}
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
SELECT t.table_id,
|
||||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
t.table_name,
|
||||||
FROM gen_table t
|
t.table_comment,
|
||||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
t.sub_table_name,
|
||||||
where t.table_id = #{id} order by c.sort
|
t.sub_table_fk_name,
|
||||||
</select>
|
t.class_name,
|
||||||
|
t.tpl_category,
|
||||||
|
t.package_name,
|
||||||
|
t.module_name,
|
||||||
|
t.business_name,
|
||||||
|
t.function_name,
|
||||||
|
t.function_author,
|
||||||
|
t.gen_type,
|
||||||
|
t.gen_path,
|
||||||
|
t.options,
|
||||||
|
t.remark,
|
||||||
|
c.column_id,
|
||||||
|
c.column_name,
|
||||||
|
c.column_comment,
|
||||||
|
c.column_type,
|
||||||
|
c.java_type,
|
||||||
|
c.java_field,
|
||||||
|
c.is_pk,
|
||||||
|
c.is_increment,
|
||||||
|
c.is_required,
|
||||||
|
c.is_insert,
|
||||||
|
c.is_edit,
|
||||||
|
c.is_list,
|
||||||
|
c.is_query,
|
||||||
|
c.query_type,
|
||||||
|
c.html_type,
|
||||||
|
c.dict_type,
|
||||||
|
c.sort
|
||||||
|
FROM gen_table t
|
||||||
|
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||||
|
where t.table_id = #{tableId}
|
||||||
|
order by c.sort
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
SELECT t.table_id,
|
||||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
t.table_name,
|
||||||
FROM gen_table t
|
t.table_comment,
|
||||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
t.sub_table_name,
|
||||||
where t.table_name = #{tableName} order by c.sort
|
t.sub_table_fk_name,
|
||||||
</select>
|
t.class_name,
|
||||||
|
t.tpl_category,
|
||||||
|
t.package_name,
|
||||||
|
t.module_name,
|
||||||
|
t.business_name,
|
||||||
|
t.function_name,
|
||||||
|
t.function_author,
|
||||||
|
t.gen_type,
|
||||||
|
t.gen_path,
|
||||||
|
t.options,
|
||||||
|
t.remark,
|
||||||
|
c.column_id,
|
||||||
|
c.column_name,
|
||||||
|
c.column_comment,
|
||||||
|
c.column_type,
|
||||||
|
c.java_type,
|
||||||
|
c.java_field,
|
||||||
|
c.is_pk,
|
||||||
|
c.is_increment,
|
||||||
|
c.is_required,
|
||||||
|
c.is_insert,
|
||||||
|
c.is_edit,
|
||||||
|
c.is_list,
|
||||||
|
c.is_query,
|
||||||
|
c.query_type,
|
||||||
|
c.html_type,
|
||||||
|
c.dict_type,
|
||||||
|
c.sort
|
||||||
|
FROM gen_table t
|
||||||
|
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||||
|
where t.table_name = #{tableName}
|
||||||
|
order by c.sort
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
|
SELECT t.table_id,
|
||||||
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
|
t.table_name,
|
||||||
FROM gen_table t
|
t.table_comment,
|
||||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
t.sub_table_name,
|
||||||
order by c.sort
|
t.sub_table_fk_name,
|
||||||
</select>
|
t.class_name,
|
||||||
<select id="selDbNameAll" resultType="java.lang.String">
|
t.tpl_category,
|
||||||
select table_schema from information_schema.tables
|
t.package_name,
|
||||||
WHERE table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys')
|
t.module_name,
|
||||||
GROUP BY table_schema
|
t.business_name,
|
||||||
</select>
|
t.function_name,
|
||||||
<select id="selFilterableByDbNameAndTableName" resultType="java.lang.String">
|
t.function_author,
|
||||||
|
t.options,
|
||||||
|
t.remark,
|
||||||
|
c.column_id,
|
||||||
|
c.column_name,
|
||||||
|
c.column_comment,
|
||||||
|
c.column_type,
|
||||||
|
c.java_type,
|
||||||
|
c.java_field,
|
||||||
|
c.is_pk,
|
||||||
|
c.is_increment,
|
||||||
|
c.is_required,
|
||||||
|
c.is_insert,
|
||||||
|
c.is_edit,
|
||||||
|
c.is_list,
|
||||||
|
c.is_query,
|
||||||
|
c.query_type,
|
||||||
|
c.html_type,
|
||||||
|
c.dict_type,
|
||||||
|
c.sort
|
||||||
|
FROM gen_table t
|
||||||
|
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||||
|
order by c.sort
|
||||||
|
</select>
|
||||||
|
|
||||||
</select>
|
<insert id="insertGenTable" parameterType="com.muyu.gen.domain.GenTable" useGeneratedKeys="true" keyProperty="tableId">
|
||||||
<select id="selectDbTableListAll" resultType="com.muyu.gen.domain.GenTableResp">
|
|
||||||
select table_name,table_comment,table_schema db_name from information_schema.tables
|
|
||||||
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%'
|
|
||||||
and table_schema in (select table_schema from information_schema.tables
|
|
||||||
WHERE table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys')
|
|
||||||
GROUP BY table_schema)
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<insert id="insertGenTable" parameterType="com.muyu.gen.domain.GenTable" useGeneratedKeys="true" keyProperty="tableId">
|
|
||||||
insert into gen_table (
|
insert into gen_table (
|
||||||
<if test="dbName != null">db_name,</if>
|
<if test="tableName != null">table_name,</if>
|
||||||
<if test="tableName != null">table_name,</if>
|
<if test="tableComment != null and tableComment != ''">table_comment,</if>
|
||||||
<if test="tableComment != null and tableComment != ''">table_comment,</if>
|
<if test="className != null and className != ''">class_name,</if>
|
||||||
<if test="className != null and className != ''">class_name,</if>
|
<if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
|
||||||
<if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
|
<if test="packageName != null and packageName != ''">package_name,</if>
|
||||||
<if test="packageName != null and packageName != ''">package_name,</if>
|
<if test="moduleName != null and moduleName != ''">module_name,</if>
|
||||||
<if test="moduleName != null and moduleName != ''">module_name,</if>
|
<if test="businessName != null and businessName != ''">business_name,</if>
|
||||||
<if test="businessName != null and businessName != ''">business_name,</if>
|
<if test="functionName != null and functionName != ''">function_name,</if>
|
||||||
<if test="functionName != null and functionName != ''">function_name,</if>
|
<if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
|
||||||
<if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
|
<if test="genType != null and genType != ''">gen_type,</if>
|
||||||
<if test="genType != null and genType != ''">gen_type,</if>
|
<if test="genPath != null and genPath != ''">gen_path,</if>
|
||||||
<if test="genPath != null and genPath != ''">gen_path,</if>
|
<if test="remark != null and remark != ''">remark,</if>
|
||||||
<if test="remark != null and remark != ''">remark,</if>
|
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
create_time
|
||||||
create_time
|
)values(
|
||||||
)values(
|
<if test="tableName != null">#{tableName},</if>
|
||||||
<if test="dbName != null">#{dbName},</if>
|
<if test="tableComment != null and tableComment != ''">#{tableComment},</if>
|
||||||
<if test="tableName != null">#{tableName},</if>
|
<if test="className != null and className != ''">#{className},</if>
|
||||||
<if test="tableComment != null and tableComment != ''">#{tableComment},</if>
|
<if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
|
||||||
<if test="className != null and className != ''">#{className},</if>
|
<if test="packageName != null and packageName != ''">#{packageName},</if>
|
||||||
<if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
|
<if test="moduleName != null and moduleName != ''">#{moduleName},</if>
|
||||||
<if test="packageName != null and packageName != ''">#{packageName},</if>
|
<if test="businessName != null and businessName != ''">#{businessName},</if>
|
||||||
<if test="moduleName != null and moduleName != ''">#{moduleName},</if>
|
<if test="functionName != null and functionName != ''">#{functionName},</if>
|
||||||
<if test="businessName != null and businessName != ''">#{businessName},</if>
|
<if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
|
||||||
<if test="functionName != null and functionName != ''">#{functionName},</if>
|
<if test="genType != null and genType != ''">#{genType},</if>
|
||||||
<if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
|
<if test="genPath != null and genPath != ''">#{genPath},</if>
|
||||||
<if test="genType != null and genType != ''">#{genType},</if>
|
<if test="remark != null and remark != ''">#{remark},</if>
|
||||||
<if test="genPath != null and genPath != ''">#{genPath},</if>
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||||
<if test="remark != null and remark != ''">#{remark},</if>
|
sysdate()
|
||||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
)
|
||||||
sysdate()
|
|
||||||
)
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateGenTable" parameterType="com.muyu.gen.domain.GenTable">
|
<update id="updateGenTable" parameterType="com.muyu.gen.domain.GenTable">
|
||||||
update gen_table
|
update gen_table
|
||||||
<set>
|
<set>
|
||||||
<if test="dbName != null">db_name = #{dbName},</if>
|
|
||||||
<if test="tableName != null">table_name = #{tableName},</if>
|
<if test="tableName != null">table_name = #{tableName},</if>
|
||||||
<if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
|
<if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
|
||||||
<if test="subTableName != null">sub_table_name = #{subTableName},</if>
|
<if test="subTableName != null">sub_table_name = #{subTableName},</if>
|
||||||
|
@ -211,7 +294,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
|
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
|
||||||
<if test="genType != null and genType != ''">gen_type = #{genType},</if>
|
<if test="genType != null and genType != ''">gen_type = #{genType},</if>
|
||||||
<if test="genPath != null and genPath != ''">gen_path = #{genPath},</if>
|
<if test="genPath != null and genPath != ''">gen_path = #{genPath},</if>
|
||||||
<if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if> <if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
|
<if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
|
||||||
|
<if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
|
||||||
<if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
|
<if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
|
||||||
<if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
|
<if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
|
||||||
<if test="functionName != null and functionName != ''">function_name = #{functionName},</if>
|
<if test="functionName != null and functionName != ''">function_name = #{functionName},</if>
|
||||||
|
@ -224,11 +308,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<delete id="deleteGenTableByIds" parameterType="Long">
|
<delete id="deleteGenTableByIds" parameterType="Long">
|
||||||
delete from gen_table where table_id in (
|
delete from gen_table where table_id in
|
||||||
<foreach collection="ids" item="tableId" separator="," >
|
<foreach collection="array" item="tableId" open="(" separator="," close=")">
|
||||||
#{tableId}
|
#{tableId}
|
||||||
</foreach>
|
</foreach>
|
||||||
)
|
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package ${packageName}.controller;
|
package ${packageName}.controller;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.io.IOException;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import javax.annotation.Resource;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
@ -12,14 +12,14 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.muyu.common.log.annotation.Log;
|
||||||
|
import com.muyu.common.log.enums.BusinessType;
|
||||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
import ${packageName}.domain.${ClassName};
|
import ${packageName}.domain.${ClassName};
|
||||||
import ${packageName}.service.I${ClassName}Service;
|
import ${packageName}.service.I${ClassName}Service;
|
||||||
import com.muyu.common.core.web.controller.BaseController;
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
#if($table.crud || $table.sub)
|
#if($table.crud || $table.sub)
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
|
@ -35,7 +35,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
@RequestMapping("/${businessName}")
|
@RequestMapping("/${businessName}")
|
||||||
public class ${ClassName}Controller extends BaseController
|
public class ${ClassName}Controller extends BaseController
|
||||||
{
|
{
|
||||||
@Resource
|
@Autowired
|
||||||
private I${ClassName}Service ${className}Service;
|
private I${ClassName}Service ${className}Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,14 +44,14 @@ public class ${ClassName}Controller extends BaseController
|
||||||
@RequiresPermissions("${permissionPrefix}:list")
|
@RequiresPermissions("${permissionPrefix}:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
#if($table.crud || $table.sub)
|
#if($table.crud || $table.sub)
|
||||||
public Result<TableDataInfo<${ClassName}>> list(${ClassName} ${className})
|
public Result<TableDataInfo> list(${ClassName} ${className})
|
||||||
{
|
{
|
||||||
startPage();
|
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);
|
||||||
}
|
}
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
public Result<${ClassName}> list(${ClassName} ${className})
|
public Result list(${ClassName} ${className})
|
||||||
{
|
{
|
||||||
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
|
||||||
return success(list);
|
return success(list);
|
||||||
|
@ -62,6 +62,7 @@ public class ${ClassName}Controller extends BaseController
|
||||||
* 导出${functionName}列表
|
* 导出${functionName}列表
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("${permissionPrefix}:export")
|
@RequiresPermissions("${permissionPrefix}:export")
|
||||||
|
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, ${ClassName} ${className})
|
public void export(HttpServletResponse response, ${ClassName} ${className})
|
||||||
{
|
{
|
||||||
|
@ -75,7 +76,7 @@ public class ${ClassName}Controller extends BaseController
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("${permissionPrefix}:query")
|
@RequiresPermissions("${permissionPrefix}:query")
|
||||||
@GetMapping(value = "/{${pkColumn.javaField}}")
|
@GetMapping(value = "/{${pkColumn.javaField}}")
|
||||||
public Result<List<${ClassName}>> getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
public Result getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
||||||
{
|
{
|
||||||
return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
|
return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
|
||||||
}
|
}
|
||||||
|
@ -84,40 +85,32 @@ public class ${ClassName}Controller extends BaseController
|
||||||
* 新增${functionName}
|
* 新增${functionName}
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("${permissionPrefix}:add")
|
@RequiresPermissions("${permissionPrefix}:add")
|
||||||
|
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public Result<Integer> add(
|
public Result add(@RequestBody ${ClassName} ${className})
|
||||||
@Validated @RequestBody ${ClassName} ${className})
|
|
||||||
{
|
{
|
||||||
if (${className}Service.checkIdUnique(${className})) {
|
return toAjax(${className}Service.insert${ClassName}(${className}));
|
||||||
return error("新增 ${functionName} '" + ${className} + "'失败,${functionName}已存在");
|
|
||||||
}
|
|
||||||
${className}.setCreateBy(SecurityUtils.getUsername());
|
|
||||||
return toAjax(${className}Service.save(${className}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改${functionName}
|
* 修改${functionName}
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("${permissionPrefix}:edit")
|
@RequiresPermissions("${permissionPrefix}:edit")
|
||||||
|
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public Result<Integer> edit(
|
public Result edit(@RequestBody ${ClassName} ${className})
|
||||||
@Validated @RequestBody ${ClassName} ${className})
|
|
||||||
{
|
{
|
||||||
if (!${className}Service.checkIdUnique(${className})) {
|
return toAjax(${className}Service.update${ClassName}(${className}));
|
||||||
return error("修改 ${functionName} '" + ${className} + "'失败,${functionName}不存在");
|
|
||||||
}
|
|
||||||
${className}.setUpdateBy(SecurityUtils.getUsername());
|
|
||||||
return toAjax(${className}Service.updateById(${className}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除${functionName}
|
* 删除${functionName}
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("${permissionPrefix}:remove")
|
@RequiresPermissions("${permissionPrefix}:remove")
|
||||||
|
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{${pkColumn.javaField}s}")
|
@DeleteMapping("/{${pkColumn.javaField}s}")
|
||||||
public Result<Integer> remove(@PathVariable("${pkColumn.javaField}s") ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
public Result remove(@PathVariable("${pkColumn.javaField}s") ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||||
{
|
{
|
||||||
${className}Service.removeBatchByIds(Arrays.asList(${pkColumn.javaField}s));
|
return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
|
||||||
return success();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,6 @@ import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
import com.muyu.common.core.web.domain.TreeEntity;
|
import com.muyu.common.core.web.domain.TreeEntity;
|
||||||
#end
|
#end
|
||||||
import lombok.*;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}对象 ${tableName}
|
* ${functionName}对象 ${tableName}
|
||||||
|
@ -23,20 +16,13 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${datetime}
|
* @date ${datetime}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if($table.crud || $table.sub)
|
#if($table.crud || $table.sub)
|
||||||
#set($Entity="BaseEntity")
|
#set($Entity="BaseEntity")
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
#set($Entity="TreeEntity")
|
#set($Entity="TreeEntity")
|
||||||
#end
|
#end
|
||||||
@Data
|
public class ${ClassName} extends ${Entity}
|
||||||
@Setter
|
{
|
||||||
@Getter
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@TableName("${tableName}")
|
|
||||||
public class ${ClassName} extends ${Entity}{
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
|
@ -58,19 +44,33 @@ public class ${ClassName} extends ${Entity}{
|
||||||
@Excel(name = "${comment}")
|
@Excel(name = "${comment}")
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
#if($column.javaField == $pkColumn.javaField)
|
|
||||||
@TableId( type = IdType.AUTO)
|
|
||||||
#end
|
|
||||||
private $column.javaType $column.javaField;
|
private $column.javaType $column.javaField;
|
||||||
|
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
/** $table.subTable.functionName信息 */
|
/** $table.subTable.functionName信息 */
|
||||||
private List<${subClassName}> ${subclassName}List;
|
private List<${subClassName}> ${subclassName}List;
|
||||||
|
|
||||||
#end
|
#end
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if(!$table.isSuperColumn($column.javaField))
|
||||||
|
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
|
||||||
|
#set($AttrName=$column.javaField)
|
||||||
|
#else
|
||||||
|
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
||||||
|
#end
|
||||||
|
public void set${AttrName}($column.javaType $column.javaField)
|
||||||
|
{
|
||||||
|
this.$column.javaField = $column.javaField;
|
||||||
|
}
|
||||||
|
|
||||||
|
public $column.javaType get${AttrName}()
|
||||||
|
{
|
||||||
|
return $column.javaField;
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
public List<${subClassName}> get${subClassName}List()
|
public List<${subClassName}> get${subClassName}List()
|
||||||
|
|
|
@ -5,8 +5,6 @@ import ${packageName}.domain.${ClassName};
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
import ${packageName}.domain.${subClassName};
|
import ${packageName}.domain.${subClassName};
|
||||||
#end
|
#end
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}Mapper接口
|
* ${functionName}Mapper接口
|
||||||
|
@ -14,7 +12,80 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${datetime}
|
* @date ${datetime}
|
||||||
*/
|
*/
|
||||||
@Mapper
|
public interface ${ClassName}Mapper
|
||||||
public interface ${ClassName}Mapper extends BaseMapper<${ClassName}>{
|
{
|
||||||
|
/**
|
||||||
|
* 查询${functionName}
|
||||||
|
*
|
||||||
|
* @param ${pkColumn.javaField} ${functionName}主键
|
||||||
|
* @return ${functionName}
|
||||||
|
*/
|
||||||
|
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询${functionName}列表
|
||||||
|
*
|
||||||
|
* @param ${className} ${functionName}
|
||||||
|
* @return ${functionName}集合
|
||||||
|
*/
|
||||||
|
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增${functionName}
|
||||||
|
*
|
||||||
|
* @param ${className} ${functionName}
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insert${ClassName}(${ClassName} ${className});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改${functionName}
|
||||||
|
*
|
||||||
|
* @param ${className} ${functionName}
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int update${ClassName}(${ClassName} ${className});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除${functionName}
|
||||||
|
*
|
||||||
|
* @param ${pkColumn.javaField} ${functionName}主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除${functionName}
|
||||||
|
*
|
||||||
|
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||||
|
#if($table.sub)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除${subTable.functionName}
|
||||||
|
*
|
||||||
|
* @param ${pkColumn.javaField}s 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增${subTable.functionName}
|
||||||
|
*
|
||||||
|
* @param ${subclassName}List ${subTable.functionName}列表
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int batch${subClassName}(List<${subClassName}> ${subclassName}List);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过${functionName}主键删除${subTable.functionName}信息
|
||||||
|
*
|
||||||
|
* @param ${pkColumn.javaField} ${functionName}ID
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int delete${subClassName}By${subTableFkClassName}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package ${packageName}.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import ${packageName}.domain.${ClassName};
|
import ${packageName}.domain.${ClassName};
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}Service接口
|
* ${functionName}Service接口
|
||||||
|
@ -10,9 +9,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${datetime}
|
* @date ${datetime}
|
||||||
*/
|
*/
|
||||||
public interface I${ClassName}Service extends IService<${ClassName}> {
|
public interface I${ClassName}Service
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* 精确查询${functionName}
|
* 查询${functionName}
|
||||||
*
|
*
|
||||||
* @param ${pkColumn.javaField} ${functionName}主键
|
* @param ${pkColumn.javaField} ${functionName}主键
|
||||||
* @return ${functionName}
|
* @return ${functionName}
|
||||||
|
@ -28,10 +28,34 @@ public interface I${ClassName}Service extends IService<${ClassName}> {
|
||||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断 ${functionName} id是否唯一
|
* 新增${functionName}
|
||||||
|
*
|
||||||
* @param ${className} ${functionName}
|
* @param ${className} ${functionName}
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
Boolean checkIdUnique(${ClassName} ${className});
|
public int insert${ClassName}(${ClassName} ${className});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改${functionName}
|
||||||
|
*
|
||||||
|
* @param ${className} ${functionName}
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int update${ClassName}(${ClassName} ${className});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除${functionName}
|
||||||
|
*
|
||||||
|
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除${functionName}信息
|
||||||
|
*
|
||||||
|
* @param ${pkColumn.javaField} ${functionName}主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField});
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.muyu.common.core.utils.DateUtils;
|
||||||
#break
|
#break
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
#if($table.sub)
|
#if($table.sub)
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -17,10 +18,6 @@ import ${packageName}.domain.${subClassName};
|
||||||
import ${packageName}.mapper.${ClassName}Mapper;
|
import ${packageName}.mapper.${ClassName}Mapper;
|
||||||
import ${packageName}.domain.${ClassName};
|
import ${packageName}.domain.${ClassName};
|
||||||
import ${packageName}.service.I${ClassName}Service;
|
import ${packageName}.service.I${ClassName}Service;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
|
||||||
import org.springframework.util.Assert;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}Service业务层处理
|
* ${functionName}Service业务层处理
|
||||||
|
@ -29,12 +26,13 @@ import org.springframework.util.Assert;
|
||||||
* @date ${datetime}
|
* @date ${datetime}
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ${ClassName}ServiceImpl
|
public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
||||||
extends ServiceImpl<${ClassName}Mapper, ${ClassName}>
|
{
|
||||||
implements I${ClassName}Service {
|
@Autowired
|
||||||
|
private ${ClassName}Mapper ${className}Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 精确查询${functionName}
|
* 查询${functionName}
|
||||||
*
|
*
|
||||||
* @param ${pkColumn.javaField} ${functionName}主键
|
* @param ${pkColumn.javaField} ${functionName}主键
|
||||||
* @return ${functionName}
|
* @return ${functionName}
|
||||||
|
@ -42,13 +40,9 @@ public class ${ClassName}ServiceImpl
|
||||||
@Override
|
@Override
|
||||||
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
|
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
|
||||||
{
|
{
|
||||||
LambdaQueryWrapper<${ClassName}> queryWrapper = new LambdaQueryWrapper<>();
|
return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
|
||||||
Assert.notNull(${pkColumn.javaField}, "${pkColumn.javaField}不可为空");
|
|
||||||
queryWrapper.eq(${ClassName}::get${pkColumn.capJavaField}, ${pkColumn.javaField});
|
|
||||||
return this.getOne(queryWrapper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询${functionName}列表
|
* 查询${functionName}列表
|
||||||
*
|
*
|
||||||
|
@ -58,58 +52,118 @@ public class ${ClassName}ServiceImpl
|
||||||
@Override
|
@Override
|
||||||
public List<${ClassName}> select${ClassName}List(${ClassName} ${className})
|
public List<${ClassName}> select${ClassName}List(${ClassName} ${className})
|
||||||
{
|
{
|
||||||
LambdaQueryWrapper<${ClassName}> queryWrapper = new LambdaQueryWrapper<>();
|
return ${className}Mapper.select${ClassName}List(${className});
|
||||||
#foreach($column in $columns)
|
|
||||||
#set($queryType=$column.queryType)
|
|
||||||
#set($javaField=$column.javaField)
|
|
||||||
#set($javaType=$column.javaType)
|
|
||||||
#set($columnName=$column.columnName)
|
|
||||||
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
|
|
||||||
#if($column.query)
|
|
||||||
#if($column.queryType == "EQ")
|
|
||||||
if (StringUtils.isNotEmpty(${className}.get${AttrName}())){
|
|
||||||
queryWrapper.eq(${ClassName}::get${AttrName}, ${className}.get${AttrName}());
|
|
||||||
}
|
|
||||||
#elseif($queryType == "NE")
|
|
||||||
if (StringUtils.isNotEmpty(${className}.get${AttrName}())){
|
|
||||||
queryWrapper.ne(${ClassName}::get${AttrName}, ${className}.get${AttrName}());
|
|
||||||
}
|
|
||||||
#elseif($queryType == "GT")
|
|
||||||
if (StringUtils.isNotEmpty(${className}.get${AttrName}())){
|
|
||||||
queryWrapper.gt(${ClassName}::get${AttrName}, ${className}.get${AttrName}());
|
|
||||||
}
|
|
||||||
#elseif($queryType == "GTE")
|
|
||||||
if (StringUtils.isNotEmpty(${className}.get${AttrName}())){
|
|
||||||
queryWrapper.ge(${ClassName}::get${AttrName}, ${className}.get${AttrName}());
|
|
||||||
}
|
|
||||||
#elseif($queryType == "LT")
|
|
||||||
if (StringUtils.isNotEmpty(${className}.get${AttrName}())){
|
|
||||||
queryWrapper.lt(${ClassName}::get${AttrName}, ${className}.get${AttrName}());
|
|
||||||
}
|
|
||||||
#elseif($queryType == "LTE")
|
|
||||||
if (StringUtils.isNotEmpty(${className}.get${AttrName}())){
|
|
||||||
queryWrapper.le(${ClassName}::get${AttrName}, ${className}.get${AttrName}());
|
|
||||||
}
|
|
||||||
#elseif($queryType == "LIKE")
|
|
||||||
if (StringUtils.isNotEmpty(${className}.get${AttrName}())){
|
|
||||||
queryWrapper.like(${ClassName}::get${AttrName}, ${className}.get${AttrName}());
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
return this.list(queryWrapper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 唯一 判断
|
* 新增${functionName}
|
||||||
* @param ${className} ${functionName}
|
*
|
||||||
* @return ${functionName}
|
* @param ${className} ${functionName}
|
||||||
*/
|
* @return 结果
|
||||||
|
*/
|
||||||
|
#if($table.sub)
|
||||||
|
@Transactional
|
||||||
|
#end
|
||||||
@Override
|
@Override
|
||||||
public Boolean checkIdUnique(${ClassName} ${className}) {
|
public int insert${ClassName}(${ClassName} ${className})
|
||||||
LambdaQueryWrapper<${ClassName}> queryWrapper = new LambdaQueryWrapper<>();
|
{
|
||||||
queryWrapper.eq(${ClassName}::get${pkColumn.capJavaField}, ${className}.get${pkColumn.capJavaField}());
|
#foreach ($column in $columns)
|
||||||
return this.count(queryWrapper) > 0;
|
#if($column.javaField == 'createTime')
|
||||||
|
${className}.setCreateTime(DateUtils.getNowDate());
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
int rows = ${className}Mapper.insert${ClassName}(${className});
|
||||||
|
insert${subClassName}(${className});
|
||||||
|
return rows;
|
||||||
|
#else
|
||||||
|
return ${className}Mapper.insert${ClassName}(${className});
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改${functionName}
|
||||||
|
*
|
||||||
|
* @param ${className} ${functionName}
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
#if($table.sub)
|
||||||
|
@Transactional
|
||||||
|
#end
|
||||||
|
@Override
|
||||||
|
public int update${ClassName}(${ClassName} ${className})
|
||||||
|
{
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.javaField == 'updateTime')
|
||||||
|
${className}.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#if($table.sub)
|
||||||
|
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${className}.get${pkColumn.capJavaField}());
|
||||||
|
insert${subClassName}(${className});
|
||||||
|
#end
|
||||||
|
return ${className}Mapper.update${ClassName}(${className});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除${functionName}
|
||||||
|
*
|
||||||
|
* @param ${pkColumn.javaField}s 需要删除的${functionName}主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
#if($table.sub)
|
||||||
|
@Transactional
|
||||||
|
#end
|
||||||
|
@Override
|
||||||
|
public int delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||||
|
{
|
||||||
|
#if($table.sub)
|
||||||
|
${className}Mapper.delete${subClassName}By${subTableFkClassName}s(${pkColumn.javaField}s);
|
||||||
|
#end
|
||||||
|
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除${functionName}信息
|
||||||
|
*
|
||||||
|
* @param ${pkColumn.javaField} ${functionName}主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
#if($table.sub)
|
||||||
|
@Transactional
|
||||||
|
#end
|
||||||
|
@Override
|
||||||
|
public int delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
|
||||||
|
{
|
||||||
|
#if($table.sub)
|
||||||
|
${className}Mapper.delete${subClassName}By${subTableFkClassName}(${pkColumn.javaField});
|
||||||
|
#end
|
||||||
|
return ${className}Mapper.delete${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
|
||||||
|
}
|
||||||
|
#if($table.sub)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增${subTable.functionName}信息
|
||||||
|
*
|
||||||
|
* @param ${className} ${functionName}对象
|
||||||
|
*/
|
||||||
|
public void insert${subClassName}(${ClassName} ${className})
|
||||||
|
{
|
||||||
|
List<${subClassName}> ${subclassName}List = ${className}.get${subClassName}List();
|
||||||
|
${pkColumn.javaType} ${pkColumn.javaField} = ${className}.get${pkColumn.capJavaField}();
|
||||||
|
if (StringUtils.isNotNull(${subclassName}List))
|
||||||
|
{
|
||||||
|
List<${subClassName}> list = new ArrayList<${subClassName}>();
|
||||||
|
for (${subClassName} ${subclassName} : ${subclassName}List)
|
||||||
|
{
|
||||||
|
${subclassName}.set${subTableFkClassName}(${pkColumn.javaField});
|
||||||
|
list.add(${subclassName});
|
||||||
|
}
|
||||||
|
if (list.size() > 0)
|
||||||
|
{
|
||||||
|
${className}Mapper.batch${subClassName}(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,8 @@ import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class ${subClassName} extends BaseEntity {
|
public class ${subClassName} extends BaseEntity
|
||||||
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
#foreach ($column in $subTable.columns)
|
#foreach ($column in $subTable.columns)
|
||||||
|
|
|
@ -353,7 +353,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "/src/api/${moduleName}/${businessName}";
|
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "${BusinessName}",
|
name: "${BusinessName}",
|
||||||
|
@ -448,8 +448,8 @@ export default {
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
list${BusinessName}(this.queryParams).then(response => {
|
list${BusinessName}(this.queryParams).then(response => {
|
||||||
this.${businessName}List = response.data.rows;
|
this.${businessName}List = response.rows;
|
||||||
this.total = response.data.total;
|
this.total = response.total;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
target/
|
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
|
||||||
!**/src/main/**/target/
|
|
||||||
!**/src/test/**/target/
|
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
|
||||||
.idea/modules.xml
|
|
||||||
.idea/jarRepositories.xml
|
|
||||||
.idea/compiler.xml
|
|
||||||
.idea/libraries/
|
|
||||||
*.iws
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
|
|
||||||
### Eclipse ###
|
|
||||||
.apt_generated
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.project
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
.sts4-cache
|
|
||||||
|
|
||||||
### NetBeans ###
|
|
||||||
/nbproject/private/
|
|
||||||
/nbbuild/
|
|
||||||
/dist/
|
|
||||||
/nbdist/
|
|
||||||
/.nb-gradle/
|
|
||||||
build/
|
|
||||||
!**/src/main/**/build/
|
|
||||||
!**/src/test/**/build/
|
|
||||||
|
|
||||||
### VS Code ###
|
|
||||||
.vscode/
|
|
||||||
|
|
||||||
### Mac OS ###
|
|
||||||
.DS_Store
|
|
|
@ -1,38 +0,0 @@
|
||||||
target/
|
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
|
||||||
!**/src/main/**/target/
|
|
||||||
!**/src/test/**/target/
|
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
|
||||||
.idea/modules.xml
|
|
||||||
.idea/jarRepositories.xml
|
|
||||||
.idea/compiler.xml
|
|
||||||
.idea/libraries/
|
|
||||||
*.iws
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
|
|
||||||
### Eclipse ###
|
|
||||||
.apt_generated
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.project
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
.sts4-cache
|
|
||||||
|
|
||||||
### NetBeans ###
|
|
||||||
/nbproject/private/
|
|
||||||
/nbbuild/
|
|
||||||
/dist/
|
|
||||||
/nbdist/
|
|
||||||
/.nb-gradle/
|
|
||||||
build/
|
|
||||||
!**/src/main/**/build/
|
|
||||||
!**/src/test/**/build/
|
|
||||||
|
|
||||||
### VS Code ###
|
|
||||||
.vscode/
|
|
||||||
|
|
||||||
### Mac OS ###
|
|
||||||
.DS_Store
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<parent>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-modules-openbusiness</artifactId>
|
|
||||||
<version>3.6.3</version>
|
|
||||||
</parent>
|
|
||||||
|
|
||||||
<artifactId>cloud-modules-openbusiness-common</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
|
||||||
<maven.compiler.target>17</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.muyu</groupId>
|
|
||||||
<artifactId>cloud-common-core</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>dom4j</groupId>
|
|
||||||
<artifactId>dom4j</artifactId>
|
|
||||||
<version>1.6.1</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.squareup.okhttp3</groupId>
|
|
||||||
<artifactId>okhttp</artifactId>
|
|
||||||
<version>4.9.3</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.thoughtworks.xstream</groupId>
|
|
||||||
<artifactId>xstream</artifactId>
|
|
||||||
<version>1.4.20</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.34</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
|
||||||
<version>3.3.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
<version>3.3.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>redis.clients</groupId>
|
|
||||||
<artifactId>jedis</artifactId>
|
|
||||||
<version>4.2.2</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
|
@ -1,93 +0,0 @@
|
||||||
package com.muyu.openbusiness.DTO;//package com.muyu.breakdown.DTO;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//import com.muyu.openbusiness.domain.Messages;
|
|
||||||
//import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
//import org.springframework.stereotype.Component;
|
|
||||||
//
|
|
||||||
//import java.sql.*;
|
|
||||||
//import java.util.*;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * @ Tool:IntelliJ IDEA
|
|
||||||
// * @ Author:CHX
|
|
||||||
// * @ Date:2024-09-18-15:00
|
|
||||||
// * @ Version:1.0
|
|
||||||
// * @ Description:数据库连接层
|
|
||||||
// * @author Lenovo
|
|
||||||
// */
|
|
||||||
//@Component
|
|
||||||
//public class MessageDTO {
|
|
||||||
// private static final String DB_URL = "jdbc:mysql://106.54.193.225:3306/one";
|
|
||||||
// private static final String USER = "root";
|
|
||||||
// private static final String PASSWORD = "bawei2112A";
|
|
||||||
//
|
|
||||||
// // 2. 建立数据库连接
|
|
||||||
// Connection connection;
|
|
||||||
// // 构造函数,初始化数据库连接
|
|
||||||
// // 保存消息到数据库
|
|
||||||
// public void saveMessage(Messages message) {
|
|
||||||
// String sql = "INSERT INTO sys_messages (sender_id, receiver_id, content) VALUES (?, ?, ?)";
|
|
||||||
// try {
|
|
||||||
// Class.forName("com.mysql.cj.jdbc.Driver");
|
|
||||||
// } catch (ClassNotFoundException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
// try {
|
|
||||||
// connection = DriverManager.getConnection(DB_URL, USER, PASSWORD);
|
|
||||||
// } catch (SQLException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
// try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
|
||||||
// preparedStatement.setInt(1, message.getSenderId());
|
|
||||||
// preparedStatement.setInt(2, message.getReceiverId());
|
|
||||||
// preparedStatement.setString(3, message.getContent());
|
|
||||||
// // 执行添加操作
|
|
||||||
// preparedStatement.executeUpdate();
|
|
||||||
// } catch (SQLException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
// try {
|
|
||||||
// connection.close();
|
|
||||||
// } catch (SQLException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // 获取所有消息
|
|
||||||
// public List<Messages> getAllMessages(int receiverId){
|
|
||||||
// String sql = "SELECT * FROM sys_messages WHERE receiver_id = ?";
|
|
||||||
// try {
|
|
||||||
// Class.forName("com.mysql.cj.jdbc.Driver");
|
|
||||||
// } catch (ClassNotFoundException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
// List<Messages> messages = new ArrayList<>();
|
|
||||||
// try {
|
|
||||||
// connection = DriverManager.getConnection(DB_URL, USER, PASSWORD);
|
|
||||||
// } catch (SQLException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
// try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
|
||||||
// preparedStatement.setInt(1, receiverId);
|
|
||||||
// // 执行查询操作
|
|
||||||
// ResultSet rs = preparedStatement.executeQuery();
|
|
||||||
// while (rs.next()) {
|
|
||||||
// Messages message = new Messages(rs.getInt("sender_id"), receiverId, rs.getString("content"));
|
|
||||||
//
|
|
||||||
// // 添加到消息列表
|
|
||||||
// messages.add(message);
|
|
||||||
// }
|
|
||||||
// } catch (SQLException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
// try {
|
|
||||||
// connection.close();
|
|
||||||
// } catch (SQLException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
// // 返回消息列表
|
|
||||||
// return messages;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package com.muyu.openbusiness.domain;
|
|
||||||
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Data
|
|
||||||
public class Animal {
|
|
||||||
@Excel
|
|
||||||
private String aId;
|
|
||||||
@Excel
|
|
||||||
private String color;
|
|
||||||
@Excel
|
|
||||||
private String hobby;
|
|
||||||
@Excel
|
|
||||||
private String aName;
|
|
||||||
}
|
|
|
@ -1,74 +0,0 @@
|
||||||
package com.muyu.openbusiness.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Lenovo
|
|
||||||
* @ Tool:IntelliJ IDEA
|
|
||||||
* @ Author:CHX
|
|
||||||
* @ Date:2024-09-17-15:10
|
|
||||||
* @ Version:1.0
|
|
||||||
* @ Description:故障实体类
|
|
||||||
*/
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@TableName("sys_car_fault")
|
|
||||||
public class BreakDown extends BaseEntity {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键
|
|
||||||
*/
|
|
||||||
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
@Excel(name = "主键")
|
|
||||||
private Long id;
|
|
||||||
/**
|
|
||||||
* 故障码
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障码")
|
|
||||||
private String faultCode;
|
|
||||||
/**
|
|
||||||
* 故障类型
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障类型")
|
|
||||||
private String faultType;
|
|
||||||
/**
|
|
||||||
* 故障标签
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障标签")
|
|
||||||
private String faultLabel;
|
|
||||||
/**
|
|
||||||
* 故障位
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障位")
|
|
||||||
private String faultBit;
|
|
||||||
/**
|
|
||||||
* 故障值
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障值")
|
|
||||||
private String faultValue;
|
|
||||||
/**
|
|
||||||
* 故障级别
|
|
||||||
*/
|
|
||||||
@Excel(name = "故障级别")
|
|
||||||
private String faultWarn;
|
|
||||||
/**
|
|
||||||
* 报警状态(Y.是,N.否)
|
|
||||||
*/
|
|
||||||
@Excel(name = "报警状态")
|
|
||||||
private String faultStatus;
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package com.muyu.openbusiness.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
|
||||||
import lombok.*;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 故障日志对象 fault_log
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
* @date 2024-09-20
|
|
||||||
*/
|
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Data
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@TableName("fault_log")
|
|
||||||
public class FaultLog extends BaseEntity{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** id */
|
|
||||||
@TableId( type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** 故障码 */
|
|
||||||
@Excel(name = "故障码")
|
|
||||||
private String faultCode;
|
|
||||||
|
|
||||||
/** 车辆VIN */
|
|
||||||
@Excel(name = "车辆VIN")
|
|
||||||
private String carVin;
|
|
||||||
|
|
||||||
/** 开始报警时间 */
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@Excel(name = "开始报警时间", width = 30, dateFormat = "yyyy-MM-dd")
|
|
||||||
private Date startTime;
|
|
||||||
|
|
||||||
/** 结束报警时间 */
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@Excel(name = "结束报警时间", width = 30, dateFormat = "yyyy-MM-dd")
|
|
||||||
private Date endTime;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
package com.muyu.openbusiness.domain;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ Tool:IntelliJ IDEA
|
|
||||||
* @ Author:CHX
|
|
||||||
* @ Date:2024-09-20-15:31
|
|
||||||
* @ Version:1.0
|
|
||||||
* @ Description:
|
|
||||||
* @author Lenovo
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@SuperBuilder
|
|
||||||
public class MessageMap {
|
|
||||||
private String key;
|
|
||||||
private String value;
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
package com.muyu.openbusiness.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ Tool:IntelliJ IDEA
|
|
||||||
* @ Author:CHX
|
|
||||||
* @ Date:2024-09-18-14:51
|
|
||||||
* @ Version:1.0
|
|
||||||
* @ Description:站内信实体类
|
|
||||||
* @author Lenovo
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@TableName("sys_messages")
|
|
||||||
public class Messages {
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
|
||||||
@Excel(name = "消息ID")
|
|
||||||
private Long id;
|
|
||||||
@Excel(name = "发送者ID")
|
|
||||||
private String senderId;
|
|
||||||
@Excel(name = "接收者ID")
|
|
||||||
private String receiverId;
|
|
||||||
@Excel(name = "消息内容")
|
|
||||||
private String content;
|
|
||||||
@Excel(name = "发送时间")
|
|
||||||
private Date createTime;
|
|
||||||
@Excel(name = "消息状态")
|
|
||||||
private String status;
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package com.muyu.openbusiness.domain;
|
|
||||||
|
|
||||||
import io.micrometer.observation.annotation.Observed;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
import lombok.ToString;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@ToString
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class Person {
|
|
||||||
private String person;
|
|
||||||
private Integer Age;
|
|
||||||
private String name;
|
|
||||||
private String Nation;
|
|
||||||
private String Animal;
|
|
||||||
private Integer id;
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
package com.muyu.openbusiness.domain;
|
|
||||||
|
|
||||||
public interface RedisService {
|
|
||||||
}
|
|
|
@ -1,27 +0,0 @@
|
||||||
package com.muyu.openbusiness.domain;
|
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
|
|
||||||
public class SerializeUtil {
|
|
||||||
public static byte[] serialize(Object object){
|
|
||||||
ObjectOutputStream oos =null;
|
|
||||||
ByteArrayOutputStream baos =null;
|
|
||||||
try{
|
|
||||||
//序列化
|
|
||||||
baos =new ByteArrayOutputStream();
|
|
||||||
oos =new ObjectOutputStream(baos);
|
|
||||||
oos.writeObject(object);
|
|
||||||
byte[] bytes =baos.toByteArray();
|
|
||||||
return bytes;
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public static Object unserialize(byte[] bytes) throws IOException {
|
|
||||||
ByteArrayInputStream bais =null;
|
|
||||||
bais =new ByteArrayInputStream(bytes);
|
|
||||||
ObjectInputStream ois =new ObjectInputStream(bais);
|
|
||||||
return ois.available();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,86 +0,0 @@
|
||||||
package com.muyu.openbusiness.domain;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
|
||||||
import lombok.*;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆基础信息对象 sys_car
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
* @date 2024-09-17
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@TableName("sys_car")
|
|
||||||
public class SysCar {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** 自增主键 */
|
|
||||||
@TableId( type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** 车辆VIN码 */
|
|
||||||
@Excel(name = "车辆VIN码")
|
|
||||||
private String carVin;
|
|
||||||
|
|
||||||
/** 车辆车牌号 */
|
|
||||||
@Excel(name = "车辆车牌号")
|
|
||||||
private String carPlate;
|
|
||||||
|
|
||||||
/** 车辆品牌 */
|
|
||||||
@Excel(name = "车辆品牌")
|
|
||||||
private String carBrand;
|
|
||||||
|
|
||||||
/** 车辆型号 */
|
|
||||||
@Excel(name = "车辆型号")
|
|
||||||
private String carModel;
|
|
||||||
|
|
||||||
/** 车辆车型(如客车,卡车,公交车等) */
|
|
||||||
@Excel(name = "车辆车型(如客车,卡车,公交车等)")
|
|
||||||
private String carType;
|
|
||||||
|
|
||||||
/** 最后一次连线时间 */
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@Excel(name = "最后一次连线时间", width = 30, dateFormat = "yyyy-MM-dd")
|
|
||||||
private Date carLastJoinTime;
|
|
||||||
|
|
||||||
/** 最后一次离线时间 */
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@Excel(name = "最后一次离线时间", width = 30, dateFormat = "yyyy-MM-dd")
|
|
||||||
private Date carLastOfflineTime;
|
|
||||||
|
|
||||||
/** 启用状态(1.在线 2.离线 3.已断开 4.待连接 5.维修中 */
|
|
||||||
@Excel(name = "启用状态(1.在线 2.离线 3.已断开 4.待连接 5.维修中")
|
|
||||||
private String state;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("carVin", getCarVin())
|
|
||||||
.append("carPlate", getCarPlate())
|
|
||||||
.append("carBrand", getCarBrand())
|
|
||||||
.append("carModel", getCarModel())
|
|
||||||
.append("carType", getCarType())
|
|
||||||
.append("carLastJoinTime", getCarLastJoinTime())
|
|
||||||
.append("carLastOfflineTime", getCarLastOfflineTime())
|
|
||||||
.append("state", getState())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package com.muyu.openbusiness.domain;
|
|
||||||
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
|
||||||
import lombok.*;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 车辆报文记录对象 sys_car_message
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
* @date 2024-09-18
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@TableName("sys_car_message")
|
|
||||||
public class SysCarMessage {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** 自增主键 */
|
|
||||||
@TableId( type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** 车辆型号编码 */
|
|
||||||
@Excel(name = "车辆型号编码")
|
|
||||||
private String modelCode;
|
|
||||||
|
|
||||||
/** 车辆报文类型编码 */
|
|
||||||
@Excel(name = "i")
|
|
||||||
private String messageTypeCode;
|
|
||||||
|
|
||||||
/** 开始位下标 */
|
|
||||||
@Excel(name = "开始位下标")
|
|
||||||
private String messageStartIndex;
|
|
||||||
|
|
||||||
/** 结束位下标 */
|
|
||||||
@Excel(name = "结束位下标")
|
|
||||||
private String messageEndIndex;
|
|
||||||
|
|
||||||
/** 报文分类 */
|
|
||||||
@Excel(name = "报文分类")
|
|
||||||
private String messageType;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("modelCode", getModelCode())
|
|
||||||
.append("messageTypeCode", getMessageTypeCode())
|
|
||||||
.append("messageStartIndex", getMessageStartIndex())
|
|
||||||
.append("messageEndIndex", getMessageEndIndex())
|
|
||||||
.append("messageType", getMessageType())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,66 +0,0 @@
|
||||||
package com.muyu.openbusiness.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import lombok.*;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 电子围栏对象 sys_corpuscle_fence
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
* @date 2024-09-17
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@TableName("sys_corpuscle_fence")
|
|
||||||
public class SysCorpuscle{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** 自增主键 */
|
|
||||||
@TableId( type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** 围栏编码 */
|
|
||||||
@Excel(name = "围栏编码")
|
|
||||||
private String fenceCode;
|
|
||||||
|
|
||||||
/** 围栏名称 */
|
|
||||||
@Excel(name = "围栏名称")
|
|
||||||
private String fenceName;
|
|
||||||
|
|
||||||
/** 围栏类型(1.驶入 2.驶出) */
|
|
||||||
@Excel(name = "围栏类型(1.驶入 2.驶出)")
|
|
||||||
private Long fenceType;
|
|
||||||
|
|
||||||
/** 围栏位置 */
|
|
||||||
@Excel(name = "围栏位置")
|
|
||||||
private String fencePosition;
|
|
||||||
|
|
||||||
/** 启用状态(1.启用 2.停用) */
|
|
||||||
@Excel(name = "启用状态(1.启用 2.停用)")
|
|
||||||
private String state;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("fenceCode", getFenceCode())
|
|
||||||
.append("fenceName", getFenceName())
|
|
||||||
.append("fenceType", getFenceType())
|
|
||||||
.append("fencePosition", getFencePosition())
|
|
||||||
.append("state", getState())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,93 +0,0 @@
|
||||||
package com.muyu.openbusiness.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import lombok.*;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 围栏组对象 sys_fence_group
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
* @date 2024-09-17
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@TableName("sys_fence_group")
|
|
||||||
public class SysFence{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/** 自增主键 */
|
|
||||||
@TableId( type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** 围栏组编码 */
|
|
||||||
@Excel(name = "围栏组编码")
|
|
||||||
private String groupCode;
|
|
||||||
|
|
||||||
/** 围栏组名称 */
|
|
||||||
@Excel(name = "围栏组名称")
|
|
||||||
private String groupName;
|
|
||||||
|
|
||||||
/** 围栏组类型 */
|
|
||||||
@Excel(name = "围栏组类型")
|
|
||||||
private String groupType;
|
|
||||||
|
|
||||||
/** 启用状态 */
|
|
||||||
@Excel(name = "启用状态")
|
|
||||||
private String state;
|
|
||||||
|
|
||||||
/** 创建人 */
|
|
||||||
@Excel(name = "创建人")
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
/** 创建时间 */
|
|
||||||
@Excel(name = "创建时间")
|
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
/** 更新人 */
|
|
||||||
@Excel(name = "更新人")
|
|
||||||
private String updateBy;
|
|
||||||
|
|
||||||
/** 更新时间 */
|
|
||||||
@Excel(name = "更新时间")
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
/** 启用状态 */
|
|
||||||
@Excel(name = "启用状态")
|
|
||||||
private String remark;
|
|
||||||
|
|
||||||
// /** sysfindname */
|
|
||||||
// @Excel(name = "电子围栏集群")
|
|
||||||
// private String sysfindname;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
.append("id", getId())
|
|
||||||
.append("groupCode", getGroupCode())
|
|
||||||
.append("groupName", getGroupName())
|
|
||||||
.append("groupType", getGroupType())
|
|
||||||
.append("state", getState())
|
|
||||||
.append("createBy", getCreateBy())
|
|
||||||
.append("createTime", getCreateTime())
|
|
||||||
.append("updateBy", getUpdateBy())
|
|
||||||
.append("updateTime", getUpdateTime())
|
|
||||||
// .append("sysfindname", getSysfindname())
|
|
||||||
.append("remark", getRemark())
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
package com.muyu.openbusiness.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
|
||||||
import lombok.*;
|
|
||||||
import lombok.experimental.SuperBuilder;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
@SuperBuilder
|
|
||||||
@NoArgsConstructor
|
|
||||||
@AllArgsConstructor
|
|
||||||
@TableName("sys_corpuscle_fence")
|
|
||||||
public class SysFenceRail {
|
|
||||||
private static final long seriaversionUID =1L;
|
|
||||||
/** 自增主键 */
|
|
||||||
@TableId(type = IdType.AUTO)
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** 围栏编码 */
|
|
||||||
@Excel(name="围栏编码")
|
|
||||||
private String fenceCode;
|
|
||||||
/**围栏名称**/
|
|
||||||
@Excel(name = "围栏名称")
|
|
||||||
private String fenceName;
|
|
||||||
|
|
||||||
/**围栏类型**/
|
|
||||||
@Excel(name = "围栏类型")
|
|
||||||
private Long fenceType;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue