diff --git a/cloud-auth/pom.xml b/cloud-auth/pom.xml index 3921e2a..66dd4f4 100644 --- a/cloud-auth/pom.xml +++ b/cloud-auth/pom.xml @@ -16,11 +16,31 @@ + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-sentinel + + + org.springframework.boot @@ -45,6 +65,7 @@ cloud-common-api-doc + com.alibaba.cloud @@ -87,6 +108,7 @@ cloud-common-log + diff --git a/cloud-auth/src/main/java/com/muyu/auth/CloudAuthApplication.java b/cloud-auth/src/main/java/com/muyu/auth/CloudAuthApplication.java index c675ad1..ba8e318 100644 --- a/cloud-auth/src/main/java/com/muyu/auth/CloudAuthApplication.java +++ b/cloud-auth/src/main/java/com/muyu/auth/CloudAuthApplication.java @@ -1,8 +1,11 @@ package com.muyu.auth; +<<<<<<< HEAD import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure; import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration; import com.muyu.common.security.annotation.EnableCustomConfig; +======= +>>>>>>> 813460c (1..) import com.muyu.common.security.annotation.EnableMyFeignClients; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -13,6 +16,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; * * @author muyu */ +<<<<<<< HEAD @EnableCustomConfig @EnableMyFeignClients @SpringBootApplication( @@ -26,5 +30,12 @@ public class CloudAuthApplication { public static void main (String[] args) { SpringApplication.run(CloudAuthApplication.class, args); System.out.println("CloudAuth 模块启动成功!"); +======= +@EnableMyFeignClients +@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}) +public class CloudAuthApplication { + public static void main (String[] args) { + SpringApplication.run(CloudAuthApplication.class, args); +>>>>>>> 813460c (1..) } } diff --git a/cloud-auth/src/main/java/com/muyu/auth/controller/TokenController.java b/cloud-auth/src/main/java/com/muyu/auth/controller/TokenController.java index 8c84466..f919f93 100644 --- a/cloud-auth/src/main/java/com/muyu/auth/controller/TokenController.java +++ b/cloud-auth/src/main/java/com/muyu/auth/controller/TokenController.java @@ -10,7 +10,11 @@ import com.muyu.common.security.auth.AuthUtil; import com.muyu.common.security.service.TokenService; import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.system.domain.LoginUser; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -25,16 +29,27 @@ import jakarta.servlet.http.HttpServletRequest; */ @RestController public class TokenController { +<<<<<<< HEAD @Resource private TokenService tokenService; @Resource +======= + @Autowired + private TokenService tokenService; + + @Autowired +>>>>>>> 813460c (1..) private SysLoginService sysLoginService; @PostMapping("login") public Result login (@RequestBody LoginBody form) { // 用户登录 +<<<<<<< HEAD LoginUser userInfo = sysLoginService.login(form); +======= + LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword()); +>>>>>>> 813460c (1..) // 获取登录token return Result.success(tokenService.createToken(userInfo)); } diff --git a/cloud-auth/src/main/java/com/muyu/auth/form/LoginBody.java b/cloud-auth/src/main/java/com/muyu/auth/form/LoginBody.java index be8e264..19fec8e 100644 --- a/cloud-auth/src/main/java/com/muyu/auth/form/LoginBody.java +++ b/cloud-auth/src/main/java/com/muyu/auth/form/LoginBody.java @@ -1,16 +1,23 @@ package com.muyu.auth.form; +<<<<<<< HEAD import lombok.Data; +======= +>>>>>>> 813460c (1..) /** * 用户登录对象 * * @author muyu */ +<<<<<<< HEAD @Data public class LoginBody { private String firmCode; +======= +public class LoginBody { +>>>>>>> 813460c (1..) /** * 用户名 */ @@ -20,4 +27,23 @@ public class LoginBody { * 用户密码 */ private String password; +<<<<<<< HEAD +======= + + 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; + } +>>>>>>> 813460c (1..) } diff --git a/cloud-auth/src/main/java/com/muyu/auth/service/SysLoginService.java b/cloud-auth/src/main/java/com/muyu/auth/service/SysLoginService.java index 929536e..38d50d6 100644 --- a/cloud-auth/src/main/java/com/muyu/auth/service/SysLoginService.java +++ b/cloud-auth/src/main/java/com/muyu/auth/service/SysLoginService.java @@ -1,6 +1,9 @@ package com.muyu.auth.service; +<<<<<<< HEAD import com.muyu.auth.form.LoginBody; +======= +>>>>>>> 813460c (1..) import com.muyu.common.core.constant.CacheConstants; import com.muyu.common.core.constant.Constants; import com.muyu.common.core.constant.SecurityConstants; @@ -13,6 +16,7 @@ import com.muyu.common.core.utils.StringUtils; import com.muyu.common.core.utils.ip.IpUtils; import com.muyu.common.redis.service.RedisService; import com.muyu.common.security.utils.SecurityUtils; +<<<<<<< HEAD import com.muyu.common.system.remote.RemoteSaasService; import com.muyu.common.system.remote.RemoteUserService; import com.muyu.common.system.domain.SysUser; @@ -23,6 +27,14 @@ import org.springframework.stereotype.Component; import java.util.Set; +======= +import com.muyu.common.system.remote.RemoteUserService; +import com.muyu.common.system.domain.SysUser; +import com.muyu.common.system.domain.LoginUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +>>>>>>> 813460c (1..) /** * 登录校验方法 * @@ -30,6 +42,7 @@ import java.util.Set; */ @Component public class SysLoginService { +<<<<<<< HEAD @Resource private RemoteUserService remoteUserService; @@ -54,6 +67,26 @@ public class SysLoginService { String password = form.getPassword(); // 用户名或密码为空 错误 if (StringUtils.isAnyBlank(firmCode, username, password)) { +======= + @Autowired + private RemoteUserService remoteUserService; + + @Autowired + private SysPasswordService passwordService; + + @Autowired + private SysRecordLogService recordLogService; + + @Autowired + private RedisService redisService; + + /** + * 登录 + */ + public LoginUser login (String username, String password) { + // 用户名或密码为空 错误 + if (StringUtils.isAnyBlank(username, password)) { +>>>>>>> 813460c (1..) recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写"); throw new ServiceException("用户/密码必须填写"); } @@ -76,7 +109,12 @@ public class SysLoginService { throw new ServiceException("很遗憾,访问IP已被列入系统黑名单"); } // 查询用户信息 +<<<<<<< HEAD Result userResult = remoteUserService.getUserInfo(firmCode, username, SecurityConstants.INNER); +======= + Result userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER); + +>>>>>>> 813460c (1..) if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) { recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在"); throw new ServiceException("登录用户:" + username + " 不存在"); @@ -86,8 +124,13 @@ public class SysLoginService { throw new ServiceException(userResult.getMsg()); } +<<<<<<< HEAD LoginUser loginUser = userResult.getData(); SysUser user = loginUser.getSysUser(); +======= + LoginUser userInfo = userResult.getData(); + SysUser user = userResult.getData().getSysUser(); +>>>>>>> 813460c (1..) if (UserStatus.DELETED.getCode().equals(user.getDelFlag())) { recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "对不起,您的账号已被删除"); throw new ServiceException("对不起,您的账号:" + username + " 已被删除"); @@ -98,8 +141,12 @@ public class SysLoginService { } passwordService.validate(user, password); recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功"); +<<<<<<< HEAD return loginUser; +======= + return userInfo; +>>>>>>> 813460c (1..) } public void logout (String loginName) { diff --git a/cloud-auth/src/main/java/com/muyu/auth/service/SysPasswordService.java b/cloud-auth/src/main/java/com/muyu/auth/service/SysPasswordService.java index 3303738..b26f9c7 100644 --- a/cloud-auth/src/main/java/com/muyu/auth/service/SysPasswordService.java +++ b/cloud-auth/src/main/java/com/muyu/auth/service/SysPasswordService.java @@ -6,7 +6,11 @@ import com.muyu.common.core.exception.ServiceException; import com.muyu.common.redis.service.RedisService; import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.system.domain.SysUser; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.stereotype.Component; import java.util.concurrent.TimeUnit; @@ -18,14 +22,22 @@ import java.util.concurrent.TimeUnit; */ @Component public class SysPasswordService { +<<<<<<< HEAD @Resource +======= + @Autowired +>>>>>>> 813460c (1..) private RedisService redisService; private int maxRetryCount = CacheConstants.PASSWORD_MAX_RETRY_COUNT; private Long lockTime = CacheConstants.PASSWORD_LOCK_TIME; +<<<<<<< HEAD @Resource +======= + @Autowired +>>>>>>> 813460c (1..) private SysRecordLogService recordLogService; /** diff --git a/cloud-auth/src/main/java/com/muyu/auth/service/SysRecordLogService.java b/cloud-auth/src/main/java/com/muyu/auth/service/SysRecordLogService.java index c4ae5e1..9ad7492 100644 --- a/cloud-auth/src/main/java/com/muyu/auth/service/SysRecordLogService.java +++ b/cloud-auth/src/main/java/com/muyu/auth/service/SysRecordLogService.java @@ -6,7 +6,11 @@ import com.muyu.common.core.utils.StringUtils; import com.muyu.common.core.utils.ip.IpUtils; import com.muyu.common.system.remote.RemoteLogService; import com.muyu.common.system.domain.SysLogininfor; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.stereotype.Component; /** @@ -16,7 +20,11 @@ import org.springframework.stereotype.Component; */ @Component public class SysRecordLogService { +<<<<<<< HEAD @Resource +======= + @Autowired +>>>>>>> 813460c (1..) private RemoteLogService remoteLogService; /** diff --git a/cloud-auth/src/main/resources/bootstrap.yml b/cloud-auth/src/main/resources/bootstrap.yml index 930ce5a..961cc8d 100644 --- a/cloud-auth/src/main/resources/bootstrap.yml +++ b/cloud-auth/src/main/resources/bootstrap.yml @@ -7,7 +7,11 @@ nacos: addr: 47.116.173.119:8848 user-name: nacos password: nacos +<<<<<<< HEAD namespace: one-saas +======= + namespace: one +>>>>>>> 813460c (1..) # Spring spring: application: @@ -40,8 +44,15 @@ spring: file-extension: yml # 共享配置 shared-configs: +<<<<<<< HEAD # 系统环境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} +>>>>>>> 813460c (1..) diff --git a/cloud-common/cloud-common-core/pom.xml b/cloud-common/cloud-common-core/pom.xml index 9654ee7..de8898d 100644 --- a/cloud-common/cloud-common-core/pom.xml +++ b/cloud-common/cloud-common-core/pom.xml @@ -16,6 +16,7 @@ + com.github.yulichang mybatis-plus-join-boot-starter @@ -168,11 +169,13 @@ cn.hutool hutool-all + org.eclipse.paho org.eclipse.paho.client.mqttv3 1.2.2 + diff --git a/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/constant/SecurityConstants.java b/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/constant/SecurityConstants.java index 0e9b22d..8ce8bd3 100644 --- a/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/constant/SecurityConstants.java +++ b/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/constant/SecurityConstants.java @@ -45,9 +45,12 @@ public class SecurityConstants { * 角色权限 */ public static final String ROLE_PERMISSION = "role_permission"; +<<<<<<< HEAD /** * SAAS请求头的key */ public static final String SAAS_KEY = "ent-code"; +======= +>>>>>>> 813460c (1..) } diff --git a/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/constant/ServiceNameConstants.java b/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/constant/ServiceNameConstants.java index fee414d..5ac04ac 100644 --- a/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/constant/ServiceNameConstants.java +++ b/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/constant/ServiceNameConstants.java @@ -20,6 +20,7 @@ public class ServiceNameConstants { * 文件服务的serviceid */ public static final String FILE_SERVICE = "cloud-file"; +<<<<<<< HEAD /** * 智能车联服务 @@ -29,4 +30,6 @@ public class ServiceNameConstants { public static final String ENT_SERVICE = "cloud-ent"; public static final String SAAS_SERVICE = "cloud-system-saas"; +======= +>>>>>>> 813460c (1..) } diff --git a/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/context/SecurityContextHolder.java b/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/context/SecurityContextHolder.java index f8866f7..1e6951b 100644 --- a/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/context/SecurityContextHolder.java +++ b/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/context/SecurityContextHolder.java @@ -80,6 +80,7 @@ public class SecurityContextHolder { public static void remove () { THREAD_LOCAL.remove(); } +<<<<<<< HEAD public static String getSaasKey() { return get(SecurityConstants.SAAS_KEY); @@ -88,4 +89,6 @@ public class SecurityContextHolder { set(SecurityConstants.SAAS_KEY,saasKey); } +======= +>>>>>>> 813460c (1..) } diff --git a/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/utils/JwtUtils.java b/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/utils/JwtUtils.java index c94e051..0ad8ffb 100644 --- a/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/utils/JwtUtils.java +++ b/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/utils/JwtUtils.java @@ -162,6 +162,7 @@ public class JwtUtils { public static String getValue (Claims claims, String key) { return Convert.toStr(claims.get(key), ""); } +<<<<<<< HEAD /** * 根据身份信息获取SAASKey @@ -173,4 +174,6 @@ public class JwtUtils { public static String getSaasKey(Claims claims) { return getValue(claims, SecurityConstants.SAAS_KEY); } +======= +>>>>>>> 813460c (1..) } diff --git a/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/utils/ip/IpUtils.java b/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/utils/ip/IpUtils.java index 297243e..471aaf9 100644 --- a/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/utils/ip/IpUtils.java +++ b/cloud-common/cloud-common-core/src/main/java/com/muyu/common/core/utils/ip/IpUtils.java @@ -58,7 +58,11 @@ public class IpUtils { ip = request.getRemoteAddr(); } +<<<<<<< HEAD return "0:0:0:0:0:0:0:1".equals(ip) ? "106.54.193.225" : getMultistageReverseProxyIp(ip); +======= + return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : getMultistageReverseProxyIp(ip); +>>>>>>> 813460c (1..) } /** @@ -70,7 +74,11 @@ public class IpUtils { */ public static boolean internalIp (String ip) { byte[] addr = textToNumericFormatV4(ip); +<<<<<<< HEAD return internalIp(addr) || "106.54.193.225".equals(ip); +======= + return internalIp(addr) || "127.0.0.1".equals(ip); +>>>>>>> 813460c (1..) } /** @@ -197,7 +205,11 @@ public class IpUtils { return InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { } +<<<<<<< HEAD return "106.54.193.225"; +======= + return "127.0.0.1"; +>>>>>>> 813460c (1..) } /** diff --git a/cloud-common/cloud-common-log/src/main/java/com/muyu/common/log/aspect/LogAspect.java b/cloud-common/cloud-common-log/src/main/java/com/muyu/common/log/aspect/LogAspect.java index b8cabc4..51efcac 100644 --- a/cloud-common/cloud-common-log/src/main/java/com/muyu/common/log/aspect/LogAspect.java +++ b/cloud-common/cloud-common-log/src/main/java/com/muyu/common/log/aspect/LogAspect.java @@ -18,7 +18,11 @@ import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.core.NamedThreadLocal; import org.springframework.http.HttpMethod; import org.springframework.stereotype.Component; @@ -48,7 +52,11 @@ public class LogAspect { */ private static final ThreadLocal TIME_THREADLOCAL = new NamedThreadLocal("Cost Time"); +<<<<<<< HEAD @Resource +======= + @Autowired +>>>>>>> 813460c (1..) private AsyncLogService asyncLogService; /** diff --git a/cloud-common/cloud-common-log/src/main/java/com/muyu/common/log/service/AsyncLogService.java b/cloud-common/cloud-common-log/src/main/java/com/muyu/common/log/service/AsyncLogService.java index ab2d064..99f7962 100644 --- a/cloud-common/cloud-common-log/src/main/java/com/muyu/common/log/service/AsyncLogService.java +++ b/cloud-common/cloud-common-log/src/main/java/com/muyu/common/log/service/AsyncLogService.java @@ -4,6 +4,7 @@ import com.muyu.common.core.constant.SecurityConstants; import com.muyu.common.system.remote.RemoteLogService; 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.stereotype.Service; @@ -14,7 +15,7 @@ import org.springframework.stereotype.Service; */ @Service public class AsyncLogService { - @Resource + @Autowired private RemoteLogService remoteLogService; /** diff --git a/cloud-common/cloud-common-rabbit/pom.xml b/cloud-common/cloud-common-rabbit/pom.xml index 53ac6d7..3681d6f 100644 --- a/cloud-common/cloud-common-rabbit/pom.xml +++ b/cloud-common/cloud-common-rabbit/pom.xml @@ -32,4 +32,7 @@ + + + diff --git a/cloud-common/cloud-common-rabbit/src/main/java/com/muyu/common/rabbit/RabbitListenerConfigurer.java b/cloud-common/cloud-common-rabbit/src/main/java/com/muyu/common/rabbit/RabbitListenerConfigurer.java new file mode 100644 index 0000000..51cb359 --- /dev/null +++ b/cloud-common/cloud-common-rabbit/src/main/java/com/muyu/common/rabbit/RabbitListenerConfigurer.java @@ -0,0 +1,41 @@ +package com.muyu.common.rabbit; + +import org.springframework.amqp.rabbit.connection.ConnectionFactory; +import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistrar; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.messaging.converter.MappingJackson2MessageConverter; +import org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory; + +@Configuration +public class RabbitListenerConfigurer implements org.springframework.amqp.rabbit.annotation.RabbitListenerConfigurer { + + static { + System.setProperty("spring.amqp.deserialization.trust.all", "true"); + } + + //以下配置RabbitMQ消息服务 + @Autowired + public ConnectionFactory connectionFactory; + + + /** + * 处理器方法工厂 + * @return + */ + @Bean + public DefaultMessageHandlerMethodFactory handlerMethodFactory() { + DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory(); + // 这里的转换器设置实现了 通过 @Payload 注解 自动反序列化message body + factory.setMessageConverter(new MappingJackson2MessageConverter()); + return factory; + } + + @Override + public void configureRabbitListeners(RabbitListenerEndpointRegistrar rabbitListenerEndpointRegistrar) { + rabbitListenerEndpointRegistrar.setMessageHandlerMethodFactory(handlerMethodFactory()); + } + +} + diff --git a/cloud-common/cloud-common-rabbit/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/cloud-common/cloud-common-rabbit/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 0b13700..bb0f995 100644 --- a/cloud-common/cloud-common-rabbit/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/cloud-common/cloud-common-rabbit/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,3 +1,7 @@ +<<<<<<< HEAD com.muyu.common.rabbit.config.RabbitListenerConfig com.muyu.common.rabbit.config.RabbitAdminConfig com.muyu.common.rabbit.config.RabbitMQMessageConverterConfig +======= +com.muyu.common.rabbit.RabbitListenerConfigurer +>>>>>>> 813460c (1..) diff --git a/cloud-common/cloud-common-redis/src/main/java/com/muyu/common/redis/service/RedisService.java b/cloud-common/cloud-common-redis/src/main/java/com/muyu/common/redis/service/RedisService.java index cbd59db..1ecd8f4 100644 --- a/cloud-common/cloud-common-redis/src/main/java/com/muyu/common/redis/service/RedisService.java +++ b/cloud-common/cloud-common-redis/src/main/java/com/muyu/common/redis/service/RedisService.java @@ -1,6 +1,10 @@ package com.muyu.common.redis.service; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.data.redis.core.BoundSetOperations; import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.RedisTemplate; @@ -18,7 +22,11 @@ import java.util.concurrent.TimeUnit; @SuppressWarnings(value = {"unchecked", "rawtypes"}) @Component public class RedisService { +<<<<<<< HEAD @Resource +======= + @Autowired +>>>>>>> 813460c (1..) public RedisTemplate redisTemplate; /** diff --git a/cloud-common/cloud-common-security/src/main/java/com/muyu/common/security/interceptor/HeaderInterceptor.java b/cloud-common/cloud-common-security/src/main/java/com/muyu/common/security/interceptor/HeaderInterceptor.java index 44cff61..14c2fbb 100644 --- a/cloud-common/cloud-common-security/src/main/java/com/muyu/common/security/interceptor/HeaderInterceptor.java +++ b/cloud-common/cloud-common-security/src/main/java/com/muyu/common/security/interceptor/HeaderInterceptor.java @@ -28,7 +28,10 @@ public class HeaderInterceptor implements AsyncHandlerInterceptor { } SecurityContextHolder.setUserId(ServletUtils.getHeader(request, SecurityConstants.DETAILS_USER_ID)); +<<<<<<< HEAD SecurityContextHolder.setSaasKey(ServletUtils.getHeader(request, SecurityConstants.SAAS_KEY)); +======= +>>>>>>> 813460c (1..) SecurityContextHolder.setUserName(ServletUtils.getHeader(request, SecurityConstants.DETAILS_USERNAME)); SecurityContextHolder.setUserKey(ServletUtils.getHeader(request, SecurityConstants.USER_KEY)); diff --git a/cloud-common/cloud-common-security/src/main/java/com/muyu/common/security/service/TokenService.java b/cloud-common/cloud-common-security/src/main/java/com/muyu/common/security/service/TokenService.java index 1161caa..a223175 100644 --- a/cloud-common/cloud-common-security/src/main/java/com/muyu/common/security/service/TokenService.java +++ b/cloud-common/cloud-common-security/src/main/java/com/muyu/common/security/service/TokenService.java @@ -12,7 +12,11 @@ import com.muyu.common.security.utils.SecurityUtils; import com.muyu.common.system.domain.LoginUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.stereotype.Component; import jakarta.servlet.http.HttpServletRequest; @@ -34,7 +38,11 @@ public class TokenService { private final static long expireTime = CacheConstants.EXPIRATION; private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY; +<<<<<<< HEAD @Resource +======= + @Autowired +>>>>>>> 813460c (1..) private RedisService redisService; /** @@ -55,11 +63,18 @@ public class TokenService { claimsMap.put(SecurityConstants.USER_KEY, token); claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId); claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName); +<<<<<<< HEAD claimsMap.put(SecurityConstants.SAAS_KEY,loginUser.getSysUser().getFirmCode()); // 接口返回信息 Map rspMap = new HashMap(); rspMap.put("access_token", JwtUtils.createToken(claimsMap)); rspMap.put("ent_code", loginUser.getSysUser().getFirmCode()); +======= + + // 接口返回信息 + Map rspMap = new HashMap(); + rspMap.put("access_token", JwtUtils.createToken(claimsMap)); +>>>>>>> 813460c (1..) rspMap.put("expires_in", expireTime); return rspMap; } diff --git a/cloud-common/cloud-common-security/src/main/java/com/muyu/common/security/utils/SecurityUtils.java b/cloud-common/cloud-common-security/src/main/java/com/muyu/common/security/utils/SecurityUtils.java index 89b57a6..f7bbfeb 100644 --- a/cloud-common/cloud-common-security/src/main/java/com/muyu/common/security/utils/SecurityUtils.java +++ b/cloud-common/cloud-common-security/src/main/java/com/muyu/common/security/utils/SecurityUtils.java @@ -30,10 +30,13 @@ public class SecurityUtils { return SecurityContextHolder.getUserName(); } +<<<<<<< HEAD public static String getSaasKey () { return SecurityContextHolder.getSaasKey(); } +======= +>>>>>>> 813460c (1..) /** * 获取用户key */ diff --git a/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/LoginUser.java b/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/LoginUser.java index 4c8aa05..e8272fe 100644 --- a/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/LoginUser.java +++ b/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/LoginUser.java @@ -63,6 +63,9 @@ public class LoginUser implements Serializable { */ private SysUser sysUser; +<<<<<<< HEAD +======= +>>>>>>> 813460c (1..) } diff --git a/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/SysDept.java b/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/SysDept.java index 6c2f7c2..d8cac92 100644 --- a/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/SysDept.java +++ b/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/SysDept.java @@ -34,8 +34,11 @@ public class SysDept extends BaseEntity { */ private Long parentId; +<<<<<<< HEAD private String firmCode; +======= +>>>>>>> 813460c (1..) /** * 祖级列表 */ diff --git a/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/SysRole.java b/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/SysRole.java index 9844e5a..c17d171 100644 --- a/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/SysRole.java +++ b/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/SysRole.java @@ -36,8 +36,11 @@ public class SysRole extends BaseEntity { @Excel(name = "角色名称") private String roleName; +<<<<<<< HEAD private String firmCode; +======= +>>>>>>> 813460c (1..) /** * 角色权限 */ diff --git a/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/SysUser.java b/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/SysUser.java index e2cde5d..4a594f4 100644 --- a/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/SysUser.java +++ b/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/domain/SysUser.java @@ -1,8 +1,11 @@ package com.muyu.common.system.domain; +<<<<<<< HEAD import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +======= +>>>>>>> 813460c (1..) import com.muyu.common.core.annotation.Excel; import com.muyu.common.core.annotation.Excel.ColumnType; import com.muyu.common.core.annotation.Excel.Type; @@ -31,7 +34,10 @@ import java.util.List; @NoArgsConstructor @AllArgsConstructor @EqualsAndHashCode(callSuper = true) +<<<<<<< HEAD @TableName("sys_user") +======= +>>>>>>> 813460c (1..) public class SysUser extends BaseEntity { private static final long serialVersionUID = 1L; @@ -39,11 +45,16 @@ public class SysUser extends BaseEntity { * 用户ID */ @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号") +<<<<<<< HEAD @TableId(type = IdType.AUTO) private Long userId; private Integer isAdmin; +======= + private Long userId; + +>>>>>>> 813460c (1..) /** * 部门ID */ @@ -56,9 +67,12 @@ public class SysUser extends BaseEntity { @Excel(name = "登录名称") private String userName; +<<<<<<< HEAD private String firmCode; +======= +>>>>>>> 813460c (1..) /** * 用户昵称 */ @@ -145,8 +159,11 @@ public class SysUser extends BaseEntity { */ private Long roleId; +<<<<<<< HEAD +======= +>>>>>>> 813460c (1..) public SysUser (Long userId) { this.userId = userId; } @@ -155,9 +172,14 @@ public class SysUser extends BaseEntity { return userId != null && 1L == userId; } +<<<<<<< HEAD public boolean isAdmin () { return isAdmin(this.userId) || (this.isAdmin != null && this.isAdmin == 1); +======= + public boolean isAdmin () { + return isAdmin(this.userId); +>>>>>>> 813460c (1..) } @Xss(message = "用户昵称不能包含脚本字符") diff --git a/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/remote/RemoteUserService.java b/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/remote/RemoteUserService.java index ca0bb3f..5ee65f0 100644 --- a/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/remote/RemoteUserService.java +++ b/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/remote/RemoteUserService.java @@ -3,6 +3,7 @@ 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; +<<<<<<< HEAD import com.muyu.common.system.domain.*; import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory; import org.springframework.cloud.openfeign.FeignClient; @@ -11,6 +12,14 @@ import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Set; +======= +import com.muyu.common.system.domain.SysUser; +import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory; +import com.muyu.common.system.domain.LoginUser; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.*; + +>>>>>>> 813460c (1..) /** * 用户服务 * @@ -18,6 +27,19 @@ import java.util.Set; */ @FeignClient(contextId = "remoteUserService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteUserFallbackFactory.class) public interface RemoteUserService { +<<<<<<< HEAD +======= + /** + * 通过用户名查询用户信息 + * + * @param username 用户名 + * @param source 请求来源 + * + * @return 结果 + */ + @GetMapping("/user/info/{username}") + public Result getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); +>>>>>>> 813460c (1..) /** * 注册用户信息 @@ -29,6 +51,7 @@ public interface RemoteUserService { */ @PostMapping("/user/register") public Result registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source); +<<<<<<< HEAD @GetMapping("/user/companyList") public Result> companyList (); @@ -98,4 +121,6 @@ public interface RemoteUserService { */ @PostMapping("/user") public Result addUser (@RequestBody SysUser user); +======= +>>>>>>> 813460c (1..) } diff --git a/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/remote/factory/RemoteUserFallbackFactory.java b/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/remote/factory/RemoteUserFallbackFactory.java index 2e0ecf6..9b99ba0 100644 --- a/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/remote/factory/RemoteUserFallbackFactory.java +++ b/cloud-common/cloud-common-system/src/main/java/com/muyu/common/system/remote/factory/RemoteUserFallbackFactory.java @@ -1,17 +1,26 @@ package com.muyu.common.system.remote.factory; import com.muyu.common.core.domain.Result; +<<<<<<< HEAD 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; +>>>>>>> 813460c (1..) import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.stereotype.Component; +<<<<<<< HEAD import java.util.List; import java.util.Set; +======= +>>>>>>> 813460c (1..) /** * 用户服务降级处理 * @@ -25,11 +34,19 @@ public class RemoteUserFallbackFactory implements FallbackFactory getUserInfo (String username, String source) { + return Result.error("获取用户失败:" + throwable.getMessage()); + } +>>>>>>> 813460c (1..) @Override public Result registerUserInfo (SysUser sysUser, String source) { return Result.error("注册用户失败:" + throwable.getMessage()); } +<<<<<<< HEAD @Override public Result> companyList() { @@ -76,6 +93,8 @@ public class RemoteUserFallbackFactory implements FallbackFactory>>>>>> 813460c (1..) }; } } diff --git a/cloud-common/cloud-common-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/cloud-common/cloud-common-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 6076e55..7c7f563 100644 --- a/cloud-common/cloud-common-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/cloud-common/cloud-common-system/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1,4 +1,7 @@ com.muyu.common.system.remote.factory.RemoteUserFallbackFactory com.muyu.common.system.remote.factory.RemoteLogFallbackFactory com.muyu.common.system.remote.factory.RemoteFileFallbackFactory +<<<<<<< HEAD com.muyu.common.system.remote.factory.RemoteSaasFallbackFactory +======= +>>>>>>> 813460c (1..) diff --git a/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/XXLJobConfig.java b/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/XXLJobConfig.java index 85ebf6f..17792ed 100644 --- a/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/XXLJobConfig.java +++ b/cloud-common/cloud-common-xxl/src/main/java/com/muyu/common/xxl/XXLJobConfig.java @@ -7,9 +7,15 @@ import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Component; @Log4j2 +<<<<<<< HEAD //@Component public class XXLJobConfig { // @Bean +======= +@Component +public class XXLJobConfig { + @Bean +>>>>>>> 813460c (1..) public XxlJobSpringExecutor xxlJobExecutor(XxlJobProperties xxlJobProperties) { if (StringUtils.isEmpty(xxlJobProperties.getAdminAddresses())){ throw new RuntimeException("请在bootstrap.yml当中配置shared-configs项,xxl-job共享配置[application-xxl-config]"); diff --git a/cloud-gateway/pom.xml b/cloud-gateway/pom.xml index 8aa98ed..93d24a7 100644 --- a/cloud-gateway/pom.xml +++ b/cloud-gateway/pom.xml @@ -81,6 +81,8 @@ knife4j-gateway-spring-boot-starter 4.5.0 + + diff --git a/cloud-gateway/src/main/java/com/muyu/gateway/CloudGatewayApplication.java b/cloud-gateway/src/main/java/com/muyu/gateway/CloudGatewayApplication.java index f962432..ad4e6b4 100644 --- a/cloud-gateway/src/main/java/com/muyu/gateway/CloudGatewayApplication.java +++ b/cloud-gateway/src/main/java/com/muyu/gateway/CloudGatewayApplication.java @@ -13,6 +13,9 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; public class CloudGatewayApplication { public static void main (String[] args) { SpringApplication.run(CloudGatewayApplication.class, args); +<<<<<<< HEAD System.out.println("CloudGateway 模块启动成功!"); +======= +>>>>>>> 813460c (1..) } } diff --git a/cloud-gateway/src/main/java/com/muyu/gateway/config/RouterFunctionConfiguration.java b/cloud-gateway/src/main/java/com/muyu/gateway/config/RouterFunctionConfiguration.java index cc95d0a..c06231f 100644 --- a/cloud-gateway/src/main/java/com/muyu/gateway/config/RouterFunctionConfiguration.java +++ b/cloud-gateway/src/main/java/com/muyu/gateway/config/RouterFunctionConfiguration.java @@ -1,7 +1,11 @@ package com.muyu.gateway.config; import com.muyu.gateway.handler.ValidateCodeHandler; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.MediaType; @@ -16,7 +20,11 @@ import org.springframework.web.reactive.function.server.RouterFunctions; */ @Configuration public class RouterFunctionConfiguration { +<<<<<<< HEAD @Resource +======= + @Autowired +>>>>>>> 813460c (1..) private ValidateCodeHandler validateCodeHandler; @SuppressWarnings("rawtypes") diff --git a/cloud-gateway/src/main/java/com/muyu/gateway/filter/AuthFilter.java b/cloud-gateway/src/main/java/com/muyu/gateway/filter/AuthFilter.java index 965c63b..144f1b0 100644 --- a/cloud-gateway/src/main/java/com/muyu/gateway/filter/AuthFilter.java +++ b/cloud-gateway/src/main/java/com/muyu/gateway/filter/AuthFilter.java @@ -12,7 +12,11 @@ import com.muyu.gateway.config.properties.IgnoreWhiteProperties; import io.jsonwebtoken.Claims; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GlobalFilter; import org.springframework.core.Ordered; @@ -31,10 +35,17 @@ public class AuthFilter implements GlobalFilter, Ordered { private static final Logger log = LoggerFactory.getLogger(AuthFilter.class); // 排除过滤的 uri 地址,nacos自行添加 +<<<<<<< HEAD @Resource private IgnoreWhiteProperties ignoreWhite; @Resource +======= + @Autowired + private IgnoreWhiteProperties ignoreWhite; + + @Autowired +>>>>>>> 813460c (1..) private RedisService redisService; @@ -63,7 +74,10 @@ public class AuthFilter implements GlobalFilter, Ordered { } String userid = JwtUtils.getUserId(claims); String username = JwtUtils.getUserName(claims); +<<<<<<< HEAD String saasKey = JwtUtils.getSaasKey(claims); +======= +>>>>>>> 813460c (1..) if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) { return unauthorizedResponse(exchange, "令牌验证失败"); } @@ -72,7 +86,10 @@ public class AuthFilter implements GlobalFilter, Ordered { addHeader(mutate, SecurityConstants.USER_KEY, userkey); addHeader(mutate, SecurityConstants.DETAILS_USER_ID, userid); addHeader(mutate, SecurityConstants.DETAILS_USERNAME, username); +<<<<<<< HEAD addHeader(mutate,SecurityConstants.SAAS_KEY,saasKey); +======= +>>>>>>> 813460c (1..) // 内部请求来源参数清除 removeHeader(mutate, SecurityConstants.FROM_SOURCE); return chain.filter(exchange.mutate().request(mutate.build()).build()); diff --git a/cloud-gateway/src/main/java/com/muyu/gateway/filter/ValidateCodeFilter.java b/cloud-gateway/src/main/java/com/muyu/gateway/filter/ValidateCodeFilter.java index ea94b85..7ec728e 100644 --- a/cloud-gateway/src/main/java/com/muyu/gateway/filter/ValidateCodeFilter.java +++ b/cloud-gateway/src/main/java/com/muyu/gateway/filter/ValidateCodeFilter.java @@ -6,7 +6,11 @@ import com.muyu.common.core.utils.ServletUtils; import com.muyu.common.core.utils.StringUtils; import com.muyu.gateway.config.properties.CaptchaProperties; import com.muyu.gateway.service.ValidateCodeService; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.cloud.gateway.filter.GatewayFilter; import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; import org.springframework.core.io.buffer.DataBuffer; @@ -29,9 +33,15 @@ public class ValidateCodeFilter extends AbstractGatewayFilterFactory { private final static String[] VALIDATE_URL = new String[]{"/auth/login", "/auth/register"}; private static final String CODE = "code"; private static final String UUID = "uuid"; +<<<<<<< HEAD @Resource private ValidateCodeService validateCodeService; @Resource +======= + @Autowired + private ValidateCodeService validateCodeService; + @Autowired +>>>>>>> 813460c (1..) private CaptchaProperties captchaProperties; @Override diff --git a/cloud-gateway/src/main/java/com/muyu/gateway/filter/XssFilter.java b/cloud-gateway/src/main/java/com/muyu/gateway/filter/XssFilter.java index 719dd4d..5997ad4 100644 --- a/cloud-gateway/src/main/java/com/muyu/gateway/filter/XssFilter.java +++ b/cloud-gateway/src/main/java/com/muyu/gateway/filter/XssFilter.java @@ -4,7 +4,11 @@ import com.muyu.common.core.utils.StringUtils; import com.muyu.common.core.utils.html.EscapeUtil; import com.muyu.gateway.config.properties.XssProperties; import io.netty.buffer.ByteBufAllocator; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GlobalFilter; @@ -31,7 +35,11 @@ import java.nio.charset.StandardCharsets; @ConditionalOnProperty(value = "security.xss.enabled", havingValue = "true") public class XssFilter implements GlobalFilter, Ordered { // 跨站脚本的 xss 配置,nacos自行添加 +<<<<<<< HEAD @Resource +======= + @Autowired +>>>>>>> 813460c (1..) private XssProperties xss; @Override diff --git a/cloud-gateway/src/main/java/com/muyu/gateway/handler/ValidateCodeHandler.java b/cloud-gateway/src/main/java/com/muyu/gateway/handler/ValidateCodeHandler.java index 3daceb5..2089d98 100644 --- a/cloud-gateway/src/main/java/com/muyu/gateway/handler/ValidateCodeHandler.java +++ b/cloud-gateway/src/main/java/com/muyu/gateway/handler/ValidateCodeHandler.java @@ -3,7 +3,11 @@ package com.muyu.gateway.handler; import com.muyu.common.core.exception.CaptchaException; import com.muyu.common.core.domain.Result; import com.muyu.gateway.service.ValidateCodeService; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.http.HttpStatus; import org.springframework.stereotype.Component; import org.springframework.web.reactive.function.BodyInserters; @@ -21,7 +25,11 @@ import java.io.IOException; */ @Component public class ValidateCodeHandler implements HandlerFunction { +<<<<<<< HEAD @Resource +======= + @Autowired +>>>>>>> 813460c (1..) private ValidateCodeService validateCodeService; @Override diff --git a/cloud-gateway/src/main/java/com/muyu/gateway/service/impl/ValidateCodeServiceImpl.java b/cloud-gateway/src/main/java/com/muyu/gateway/service/impl/ValidateCodeServiceImpl.java index 8e00059..5eb7a06 100644 --- a/cloud-gateway/src/main/java/com/muyu/gateway/service/impl/ValidateCodeServiceImpl.java +++ b/cloud-gateway/src/main/java/com/muyu/gateway/service/impl/ValidateCodeServiceImpl.java @@ -12,7 +12,11 @@ import com.muyu.common.redis.service.RedisService; import com.muyu.gateway.config.properties.CaptchaProperties; import com.muyu.gateway.model.resp.CaptchaCodeResp; import com.muyu.gateway.service.ValidateCodeService; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.stereotype.Service; import org.springframework.util.FastByteArrayOutputStream; @@ -35,10 +39,17 @@ public class ValidateCodeServiceImpl implements ValidateCodeService { @Resource(name = "captchaProducerMath") private Producer captchaProducerMath; +<<<<<<< HEAD @Resource private RedisService redisService; @Resource +======= + @Autowired + private RedisService redisService; + + @Autowired +>>>>>>> 813460c (1..) private CaptchaProperties captchaProperties; /** @@ -50,7 +61,11 @@ public class ValidateCodeServiceImpl implements ValidateCodeService { CaptchaCodeResp.CaptchaCodeRespBuilder respBuilder = CaptchaCodeResp.builder() .captchaEnabled(captchaEnabled); if (!captchaEnabled) { +<<<<<<< HEAD return Result.success(respBuilder.build()); +======= + return Result.success(respBuilder); +>>>>>>> 813460c (1..) } // 保存验证码信息 diff --git a/cloud-gateway/src/main/java/com/muyu/gateway/utils/WebFrameworkUtils.java b/cloud-gateway/src/main/java/com/muyu/gateway/utils/WebFrameworkUtils.java index 68b0a19..2702743 100644 --- a/cloud-gateway/src/main/java/com/muyu/gateway/utils/WebFrameworkUtils.java +++ b/cloud-gateway/src/main/java/com/muyu/gateway/utils/WebFrameworkUtils.java @@ -4,6 +4,11 @@ import cn.hutool.core.net.NetUtil; import cn.hutool.core.util.ArrayUtil; import com.alibaba.fastjson2.JSONObject; import lombok.extern.log4j.Log4j2; +<<<<<<< HEAD +======= +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +>>>>>>> 813460c (1..) import org.springframework.cloud.gateway.route.Route; import org.springframework.cloud.gateway.support.ServerWebExchangeUtils; import org.springframework.core.io.buffer.DataBufferFactory; @@ -16,6 +21,11 @@ import reactor.core.publisher.Mono; /** * Web 工具类 +<<<<<<< HEAD +======= + * + * +>>>>>>> 813460c (1..) */ @Log4j2 public class WebFrameworkUtils { @@ -68,6 +78,11 @@ public class WebFrameworkUtils { /** * 获得客户端 IP +<<<<<<< HEAD +======= + * + * +>>>>>>> 813460c (1..) * @param exchange 请求 * @param otherHeaderNames 其它 header 名字的数组 * @return 客户端 IP @@ -85,6 +100,10 @@ public class WebFrameworkUtils { return NetUtil.getMultistageReverseProxyIp(ip); } } +<<<<<<< HEAD +======= + +>>>>>>> 813460c (1..) // 方式二,通过 remoteAddress 获取 if (exchange.getRequest().getRemoteAddress() == null) { return null; @@ -95,6 +114,10 @@ public class WebFrameworkUtils { /** * 获得请求匹配的 Route 路由 +<<<<<<< HEAD +======= + * +>>>>>>> 813460c (1..) * @param exchange 请求 * @return 路由 */ diff --git a/cloud-gateway/src/main/resources/bootstrap.yml b/cloud-gateway/src/main/resources/bootstrap.yml index 3782dab..d4de70e 100644 --- a/cloud-gateway/src/main/resources/bootstrap.yml +++ b/cloud-gateway/src/main/resources/bootstrap.yml @@ -7,7 +7,11 @@ nacos: addr: 47.116.173.119:8848 user-name: nacos password: nacos +<<<<<<< HEAD namespace: one-saas +======= + namespace: one +>>>>>>> 813460c (1..) # Spring spring: @@ -22,35 +26,60 @@ spring: discovery: # 服务注册地址 server-addr: ${nacos.addr} +<<<<<<< HEAD # # nacos用户名 # username: ${nacos.user-name} # # nacos密码 # password: ${nacos.password} +======= + # nacos用户名 + username: ${nacos.user-name} + # nacos密码 + password: ${nacos.password} +>>>>>>> 813460c (1..) # 命名空间 namespace: ${nacos.namespace} config: # 服务注册地址 server-addr: ${nacos.addr} +<<<<<<< HEAD # # nacos用户名 # username: ${nacos.user-name} # # nacos密码 # password: ${nacos.password} +======= + # nacos用户名 + username: ${nacos.user-name} + # nacos密码 + password: ${nacos.password} +>>>>>>> 813460c (1..) # 命名空间 namespace: ${nacos.namespace} # 配置文件格式 file-extension: yml # 共享配置 shared-configs: +<<<<<<< HEAD # 系统环境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} +>>>>>>> 813460c (1..) sentinel: # 取消控制台懒加载 eager: true transport: # 控制台地址 +<<<<<<< HEAD dashboard: 106.54.193.225:8718 +======= + dashboard: 127.0.0.1:8718 +>>>>>>> 813460c (1..) # nacos配置持久化 datasource: ds1: diff --git a/cloud-modules/cloud-modules-file/src/main/java/com/muyu/file/CloudFileApplication.java b/cloud-modules/cloud-modules-file/src/main/java/com/muyu/file/CloudFileApplication.java index a7b6fcc..f51ff9b 100644 --- a/cloud-modules/cloud-modules-file/src/main/java/com/muyu/file/CloudFileApplication.java +++ b/cloud-modules/cloud-modules-file/src/main/java/com/muyu/file/CloudFileApplication.java @@ -13,6 +13,9 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; public class CloudFileApplication { public static void main (String[] args) { SpringApplication.run(CloudFileApplication.class, args); +<<<<<<< HEAD System.out.println("CloudFile 模块启动成功!"); +======= +>>>>>>> 813460c (1..) } } diff --git a/cloud-modules/cloud-modules-file/src/main/java/com/muyu/file/controller/SysFileController.java b/cloud-modules/cloud-modules-file/src/main/java/com/muyu/file/controller/SysFileController.java index fa9ff45..46acd5d 100644 --- a/cloud-modules/cloud-modules-file/src/main/java/com/muyu/file/controller/SysFileController.java +++ b/cloud-modules/cloud-modules-file/src/main/java/com/muyu/file/controller/SysFileController.java @@ -6,7 +6,11 @@ import com.muyu.file.service.ISysFileService; import com.muyu.common.system.domain.SysFile; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -21,7 +25,11 @@ import org.springframework.web.multipart.MultipartFile; public class SysFileController { private static final Logger log = LoggerFactory.getLogger(SysFileController.class); +<<<<<<< HEAD @Resource +======= + @Autowired +>>>>>>> 813460c (1..) private ISysFileService sysFileService; /** diff --git a/cloud-modules/cloud-modules-file/src/main/java/com/muyu/file/service/MinioSysFileServiceImpl.java b/cloud-modules/cloud-modules-file/src/main/java/com/muyu/file/service/MinioSysFileServiceImpl.java index 29dfe17..54a1dc2 100644 --- a/cloud-modules/cloud-modules-file/src/main/java/com/muyu/file/service/MinioSysFileServiceImpl.java +++ b/cloud-modules/cloud-modules-file/src/main/java/com/muyu/file/service/MinioSysFileServiceImpl.java @@ -5,7 +5,11 @@ import com.muyu.file.config.MinioConfig; import com.muyu.file.utils.FileUploadUtils; import io.minio.MinioClient; import io.minio.PutObjectArgs; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -18,10 +22,17 @@ import java.io.InputStream; */ @Service public class MinioSysFileServiceImpl implements ISysFileService { +<<<<<<< HEAD @Resource private MinioConfig minioConfig; @Resource +======= + @Autowired + private MinioConfig minioConfig; + + @Autowired +>>>>>>> 813460c (1..) private MinioClient client; /** diff --git a/cloud-modules/cloud-modules-file/src/main/resources/bootstrap.yml b/cloud-modules/cloud-modules-file/src/main/resources/bootstrap.yml index a36bd1b..aa87d67 100644 --- a/cloud-modules/cloud-modules-file/src/main/resources/bootstrap.yml +++ b/cloud-modules/cloud-modules-file/src/main/resources/bootstrap.yml @@ -1,13 +1,21 @@ # Tomcat server: +<<<<<<< HEAD port: 9301 +======= + port: 9300 +>>>>>>> 813460c (1..) # nacos线上地址 nacos: addr: 47.116.173.119:8848 user-name: nacos password: nacos +<<<<<<< HEAD namespace: one-saas +======= + namespace: one +>>>>>>> 813460c (1..) # Spring spring: diff --git a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/CloudGenApplication.java b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/CloudGenApplication.java index 3cb1f39..d44c48c 100644 --- a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/CloudGenApplication.java +++ b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/CloudGenApplication.java @@ -16,6 +16,9 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; public class CloudGenApplication { public static void main (String[] args) { SpringApplication.run(CloudGenApplication.class, args); +<<<<<<< HEAD System.out.println("CloudGen 模块启动成功!"); +======= +>>>>>>> 813460c (1..) } } diff --git a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/controller/GenController.java b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/controller/GenController.java index f93075e..3ef9d92 100644 --- a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/controller/GenController.java +++ b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/controller/GenController.java @@ -1,14 +1,21 @@ package com.muyu.gen.controller; +<<<<<<< HEAD import com.muyu.common.core.domain.Result; import com.muyu.common.core.text.Convert; import com.muyu.common.core.web.controller.BaseController; +======= +import com.muyu.common.core.text.Convert; +import com.muyu.common.core.web.controller.BaseController; +import com.muyu.common.core.domain.Result; +>>>>>>> 813460c (1..) import com.muyu.common.core.web.page.TableDataInfo; import com.muyu.common.log.annotation.Log; import com.muyu.common.log.enums.BusinessType; import com.muyu.common.security.annotation.RequiresPermissions; import com.muyu.gen.domain.GenTable; import com.muyu.gen.domain.GenTableColumn; +<<<<<<< HEAD import com.muyu.gen.domain.GenTableResp; import com.muyu.gen.service.IGenTableColumnService; import com.muyu.gen.service.IGenTableService; @@ -19,6 +26,16 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +======= +import com.muyu.gen.service.IGenTableColumnService; +import com.muyu.gen.service.IGenTableService; +import org.apache.commons.io.IOUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import jakarta.servlet.http.HttpServletResponse; +>>>>>>> 813460c (1..) import java.io.IOException; import java.util.HashMap; import java.util.List; @@ -27,6 +44,7 @@ import java.util.Map; /** * 代码生成 操作处理 * +<<<<<<< HEAD * @author ruoyi */ @RequestMapping("/gen") @@ -40,6 +58,17 @@ public class GenController extends BaseController private HttpServletResponse response; @Resource +======= + * @author muyu + */ +@RequestMapping("/gen") +@RestController +public class GenController extends BaseController { + @Autowired + private IGenTableService genTableService; + + @Autowired +>>>>>>> 813460c (1..) private IGenTableColumnService genTableColumnService; /** @@ -47,8 +76,12 @@ public class GenController extends BaseController */ @RequiresPermissions("tool:gen:list") @GetMapping("/list") +<<<<<<< HEAD public Result genList(GenTable genTable) { +======= + public Result> genList (GenTable genTable) { +>>>>>>> 813460c (1..) startPage(); List list = genTableService.selectGenTableList(genTable); return getDataTable(list); @@ -59,8 +92,12 @@ public class GenController extends BaseController */ @RequiresPermissions("tool:gen:query") @GetMapping(value = "/{tableId}") +<<<<<<< HEAD public Result getInfo(@PathVariable("tableId") Long tableId) { +======= + public Result getInfo (@PathVariable("tableId") Long tableId) { +>>>>>>> 813460c (1..) GenTable table = genTableService.selectGenTableById(tableId); List tables = genTableService.selectGenTableAll(); List list = genTableColumnService.selectGenTableColumnListByTableId(tableId); @@ -71,14 +108,21 @@ public class GenController extends BaseController return success(map); } +<<<<<<< HEAD +======= +>>>>>>> 813460c (1..) /** * 查询数据库列表 */ @RequiresPermissions("tool:gen:list") @GetMapping("/db/list") +<<<<<<< HEAD public Result dataList(GenTable genTable) { +======= + public Result> dataList (GenTable genTable) { +>>>>>>> 813460c (1..) startPage(); List list = genTableService.selectDbTableList(genTable); return getDataTable(list); @@ -88,6 +132,7 @@ public class GenController extends BaseController * 查询数据表字段列表 */ @GetMapping(value = "/column/{tableId}") +<<<<<<< HEAD public Result columnList(@PathVariable("tableId") Long tableId) { TableDataInfo dataInfo = new TableDataInfo(); @@ -95,11 +140,22 @@ public class GenController extends BaseController dataInfo.setRows(list); dataInfo.setTotal(list.size()); return success(dataInfo); +======= + public Result> columnList (Long tableId) { + List list = genTableColumnService.selectGenTableColumnListByTableId(tableId); + return Result.success( + TableDataInfo.builder() + .total(list.size()) + .rows(list) + .build() + ); +>>>>>>> 813460c (1..) } /** * 导入表结构(保存) */ +<<<<<<< HEAD // @RequiresPermissions("tool:gen:import") @Log(title = "代码生成", businessType = BusinessType.IMPORT) @PostMapping("/importTable") @@ -108,6 +164,15 @@ public class GenController extends BaseController String[] tableNames = Convert.toStrArray(tables); // 查询表信息 List tableList = genTableService.selectDbTableListByNames(tableNames,dbName); +======= + @RequiresPermissions("tool:gen:import") + @Log(title = "代码生成", businessType = BusinessType.IMPORT) + @PostMapping("/importTable") + public Result importTableSave (String tables) { + String[] tableNames = Convert.toStrArray(tables); + // 查询表信息 + List tableList = genTableService.selectDbTableListByNames(tableNames); +>>>>>>> 813460c (1..) genTableService.importGenTable(tableList); return success(); } @@ -118,8 +183,12 @@ public class GenController extends BaseController @RequiresPermissions("tool:gen:edit") @Log(title = "代码生成", businessType = BusinessType.UPDATE) @PutMapping +<<<<<<< HEAD public Result editSave(@Validated @RequestBody GenTable genTable) { +======= + public Result editSave (@Validated @RequestBody GenTable genTable) { +>>>>>>> 813460c (1..) genTableService.validateEdit(genTable); genTableService.updateGenTable(genTable); return success(); @@ -131,8 +200,12 @@ public class GenController extends BaseController @RequiresPermissions("tool:gen:remove") @Log(title = "代码生成", businessType = BusinessType.DELETE) @DeleteMapping("/{tableIds}") +<<<<<<< HEAD public Result remove(@PathVariable("tableIds") Long[] tableIds) { +======= + public Result remove (@PathVariable("tableIds") Long[] tableIds) { +>>>>>>> 813460c (1..) genTableService.deleteGenTableByIds(tableIds); return success(); } @@ -142,8 +215,12 @@ public class GenController extends BaseController */ @RequiresPermissions("tool:gen:preview") @GetMapping("/preview/{tableId}") +<<<<<<< HEAD public Result preview(@PathVariable("tableId") Long tableId) throws IOException { +======= + public Result preview (@PathVariable("tableId") Long tableId) throws IOException { +>>>>>>> 813460c (1..) Map dataMap = genTableService.previewCode(tableId); return success(dataMap); } @@ -154,8 +231,12 @@ public class GenController extends BaseController @RequiresPermissions("tool:gen:code") @Log(title = "代码生成", businessType = BusinessType.GENCODE) @GetMapping("/download/{tableName}") +<<<<<<< HEAD public void download(@PathVariable("tableName") String tableName) throws IOException { +======= + public void download (HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException { +>>>>>>> 813460c (1..) byte[] data = genTableService.downloadCode(tableName); genCode(response, data); } @@ -166,8 +247,12 @@ public class GenController extends BaseController @RequiresPermissions("tool:gen:code") @Log(title = "代码生成", businessType = BusinessType.GENCODE) @GetMapping("/genCode/{tableName}") +<<<<<<< HEAD public Result genCode(@PathVariable("tableName") String tableName) { +======= + public Result genCode (@PathVariable("tableName") String tableName) { +>>>>>>> 813460c (1..) genTableService.generatorCode(tableName); return success(); } @@ -177,10 +262,16 @@ public class GenController extends BaseController */ @RequiresPermissions("tool:gen:edit") @Log(title = "代码生成", businessType = BusinessType.UPDATE) +<<<<<<< HEAD @GetMapping("/synchDb/{tableName}/{dbName}") public Result synchDb(@PathVariable("tableName") String tableName,@PathVariable("dbName") String dbName) { genTableService.synchDb(tableName,dbName); +======= + @GetMapping("/synchDb/{tableName}") + public Result synchDb (@PathVariable("tableName") String tableName) { + genTableService.synchDb(tableName); +>>>>>>> 813460c (1..) return success(); } @@ -190,8 +281,12 @@ public class GenController extends BaseController @RequiresPermissions("tool:gen:code") @Log(title = "代码生成", businessType = BusinessType.GENCODE) @GetMapping("/batchGenCode") +<<<<<<< HEAD public void batchGenCode(@RequestParam("tables") String tables) throws IOException { +======= + public void batchGenCode (HttpServletResponse response, String tables) throws IOException { +>>>>>>> 813460c (1..) String[] tableNames = Convert.toStrArray(tables); byte[] data = genTableService.downloadCode(tableNames); genCode(response, data); @@ -200,6 +295,7 @@ public class GenController extends BaseController /** * 生成zip文件 */ +<<<<<<< HEAD private void genCode(HttpServletResponse response, byte[] data) throws IOException { response.reset(); @@ -233,4 +329,13 @@ public class GenController extends BaseController List genTableColumns = genTableColumnService.selectDbTableColumnsByName(table, dbName); return Result.success(genTableColumns); } +======= + private void genCode (HttpServletResponse response, byte[] data) throws IOException { + response.reset(); + response.setHeader("Content-Disposition", "attachment; filename=\"muyu.zip\""); + response.addHeader("Content-Length", String.valueOf(data.length)); + response.setContentType("application/octet-stream; charset=UTF-8"); + IOUtils.write(data, response.getOutputStream()); + } +>>>>>>> 813460c (1..) } diff --git a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/domain/GenTable.java b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/domain/GenTable.java index c906725..5ff551f 100644 --- a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/domain/GenTable.java +++ b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/domain/GenTable.java @@ -35,8 +35,11 @@ public class GenTable extends BaseEntity { */ private Long tableId; +<<<<<<< HEAD private String dbName; +======= +>>>>>>> 813460c (1..) /** * 表名称 */ diff --git a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableColumnMapper.java b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableColumnMapper.java index 76f5909..f757d36 100644 --- a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableColumnMapper.java +++ b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableColumnMapper.java @@ -1,5 +1,6 @@ package com.muyu.gen.mapper; +<<<<<<< HEAD import com.muyu.gen.domain.GenTableColumn; import org.apache.ibatis.annotations.Param; @@ -13,52 +14,107 @@ import java.util.List; */ public interface GenTableColumnMapper { +======= +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.muyu.gen.domain.GenTableColumn; + +import java.util.List; + +/** + * 业务字段 数据层 + * + * @author muyu + */ +public interface GenTableColumnMapper extends BaseMapper { +>>>>>>> 813460c (1..) /** * 根据表名称查询列信息 * * @param tableName 表名称 +<<<<<<< HEAD * @param dbName * @return 列信息 */ public List selectDbTableColumnsByName(@Param("tableName") String tableName, @Param("dbName") String dbName); +======= + * + * @return 列信息 + */ + List selectDbTableColumnsByName (String tableName); +>>>>>>> 813460c (1..) /** * 查询业务字段列表 * * @param tableId 业务字段编号 +<<<<<<< HEAD * @return 业务字段集合 */ public List selectGenTableColumnListByTableId(@Param("tableId") Long tableId); +======= + * + * @return 业务字段集合 + */ + List selectGenTableColumnListByTableId (Long tableId); +>>>>>>> 813460c (1..) /** * 新增业务字段 * * @param genTableColumn 业务字段信息 +<<<<<<< HEAD * @return 结果 */ public int insertGenTableColumn(GenTableColumn genTableColumn); +======= + * + * @return 结果 + */ + int insertGenTableColumn (GenTableColumn genTableColumn); +>>>>>>> 813460c (1..) /** * 修改业务字段 * * @param genTableColumn 业务字段信息 +<<<<<<< HEAD * @return 结果 */ public int updateGenTableColumn(GenTableColumn genTableColumn); +======= + * + * @return 结果 + */ + int updateGenTableColumn (GenTableColumn genTableColumn); +>>>>>>> 813460c (1..) /** * 删除业务字段 * * @param genTableColumns 列数据 +<<<<<<< HEAD * @return 结果 */ public int deleteGenTableColumns(@Param("genTableColumns") List genTableColumns); +======= + * + * @return 结果 + */ + int deleteGenTableColumns (List genTableColumns); +>>>>>>> 813460c (1..) /** * 批量删除业务字段 * * @param ids 需要删除的数据ID +<<<<<<< HEAD * @return 结果 */ public int deleteGenTableColumnByIds(@Param("ids") Long[] ids); +======= + * + * @return 结果 + */ + int deleteGenTableColumnByIds (Long[] ids); +>>>>>>> 813460c (1..) } diff --git a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableMapper.java b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableMapper.java index aa49b3f..73c43d3 100644 --- a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableMapper.java +++ b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/mapper/GenTableMapper.java @@ -1,86 +1,151 @@ package com.muyu.gen.mapper; +<<<<<<< HEAD import com.muyu.gen.domain.GenTable; import com.muyu.gen.domain.GenTableResp; import org.apache.ibatis.annotations.Param; +======= +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.muyu.gen.domain.GenTable; +>>>>>>> 813460c (1..) import java.util.List; /** * 业务 数据层 * +<<<<<<< HEAD * @author ruoyi */ public interface GenTableMapper { +======= + * @author muyu + */ +public interface GenTableMapper extends BaseMapper { +>>>>>>> 813460c (1..) /** * 查询业务列表 * * @param genTable 业务信息 +<<<<<<< HEAD * @return 业务集合 */ public List selectGenTableList(GenTable genTable); +======= + * + * @return 业务集合 + */ + List selectGenTableList (GenTable genTable); +>>>>>>> 813460c (1..) /** * 查询据库列表 * * @param genTable 业务信息 +<<<<<<< HEAD * @return 数据库表集合 */ public List selectDbTableList(GenTable genTable); +======= + * + * @return 数据库表集合 + */ + List selectDbTableList (GenTable genTable); +>>>>>>> 813460c (1..) /** * 查询据库列表 * * @param tableNames 表名称组 +<<<<<<< HEAD * @param dbName * @return 数据库表集合 */ public List selectDbTableListByNames(@Param("tableNames") String[] tableNames, @Param("dbName") String dbName); +======= + * + * @return 数据库表集合 + */ + List selectDbTableListByNames (String[] tableNames); +>>>>>>> 813460c (1..) /** * 查询所有表信息 * * @return 表信息集合 */ +<<<<<<< HEAD public List selectGenTableAll(); +======= + List selectGenTableAll (); +>>>>>>> 813460c (1..) /** * 查询表ID业务信息 * * @param id 业务ID +<<<<<<< HEAD * @return 业务信息 */ public GenTable selectGenTableById(@Param("id") Long id); +======= + * + * @return 业务信息 + */ + GenTable selectGenTableById (Long id); +>>>>>>> 813460c (1..) /** * 查询表名称业务信息 * * @param tableName 表名称 +<<<<<<< HEAD * @return 业务信息 */ public GenTable selectGenTableByName(@Param("tableName") String tableName); +======= + * + * @return 业务信息 + */ + GenTable selectGenTableByName (String tableName); +>>>>>>> 813460c (1..) /** * 新增业务 * * @param genTable 业务信息 +<<<<<<< HEAD * @return 结果 */ public int insertGenTable(GenTable genTable); +======= + * + * @return 结果 + */ + int insertGenTable (GenTable genTable); +>>>>>>> 813460c (1..) /** * 修改业务 * * @param genTable 业务信息 +<<<<<<< HEAD * @return 结果 */ public int updateGenTable(GenTable genTable); +======= + * + * @return 结果 + */ + int updateGenTable (GenTable genTable); +>>>>>>> 813460c (1..) /** * 批量删除业务 * * @param ids 需要删除的数据ID +<<<<<<< HEAD * @return 结果 */ public int deleteGenTableByIds(@Param("ids") Long[] ids); @@ -88,4 +153,10 @@ public interface GenTableMapper List selDbNameAll(); List selectDbTableListAll(); +======= + * + * @return 结果 + */ + int deleteGenTableByIds (Long[] ids); +>>>>>>> 813460c (1..) } diff --git a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableColumnServiceImpl.java b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableColumnServiceImpl.java index 043c83b..3ba99ea 100644 --- a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableColumnServiceImpl.java +++ b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableColumnServiceImpl.java @@ -3,7 +3,11 @@ package com.muyu.gen.service; import com.muyu.common.core.text.Convert; import com.muyu.gen.domain.GenTableColumn; import com.muyu.gen.mapper.GenTableColumnMapper; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.stereotype.Service; import java.util.List; @@ -11,6 +15,7 @@ import java.util.List; /** * 业务字段 服务层实现 * +<<<<<<< HEAD * @author ruoyi */ @Service @@ -30,11 +35,32 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService { return genTableColumnMapper.selectGenTableColumnListByTableId(tableId); } +======= + * @author muyu + */ +@Service +public class GenTableColumnServiceImpl implements IGenTableColumnService { + @Autowired + private GenTableColumnMapper genTableColumnMapper; + + /** + * 查询业务字段列表 + * + * @param tableId 业务字段编号 + * + * @return 业务字段集合 + */ + @Override + public List selectGenTableColumnListByTableId (Long tableId) { + return genTableColumnMapper.selectGenTableColumnListByTableId(tableId); + } +>>>>>>> 813460c (1..) /** * 新增业务字段 * * @param genTableColumn 业务字段信息 +<<<<<<< HEAD * @return 结果 */ @Override @@ -70,5 +96,37 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService @Override public List selectDbTableColumnsByName(String table, String dbName) { return genTableColumnMapper.selectDbTableColumnsByName(table,dbName); +======= + * + * @return 结果 + */ + @Override + public int insertGenTableColumn (GenTableColumn genTableColumn) { + return genTableColumnMapper.insertGenTableColumn(genTableColumn); + } + + /** + * 修改业务字段 + * + * @param genTableColumn 业务字段信息 + * + * @return 结果 + */ + @Override + public int updateGenTableColumn (GenTableColumn genTableColumn) { + return genTableColumnMapper.updateGenTableColumn(genTableColumn); + } + + /** + * 删除业务字段对象 + * + * @param ids 需要删除的数据ID + * + * @return 结果 + */ + @Override + public int deleteGenTableColumnByIds (String ids) { + return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids)); +>>>>>>> 813460c (1..) } } diff --git a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableServiceImpl.java b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableServiceImpl.java index 8cdefc5..61005ff 100644 --- a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableServiceImpl.java +++ b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/GenTableServiceImpl.java @@ -10,7 +10,10 @@ import com.muyu.common.core.utils.StringUtils; import com.muyu.common.security.utils.SecurityUtils; import com.muyu.gen.domain.GenTable; import com.muyu.gen.domain.GenTableColumn; +<<<<<<< HEAD import com.muyu.gen.domain.GenTableResp; +======= +>>>>>>> 813460c (1..) import com.muyu.gen.mapper.GenTableColumnMapper; import com.muyu.gen.mapper.GenTableMapper; import com.muyu.gen.util.GenUtils; @@ -23,7 +26,11 @@ import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +<<<<<<< HEAD import javax.annotation.Resource; +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -42,6 +49,7 @@ import java.util.zip.ZipOutputStream; /** * 业务 服务层实现 * +<<<<<<< HEAD * @author ruoyi */ @Service @@ -64,6 +72,45 @@ public class GenTableServiceImpl implements IGenTableService @Override public GenTable selectGenTableById(Long id) { +======= + * @author muyu + */ +@Service +public class GenTableServiceImpl implements IGenTableService { + private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class); + + @Autowired + private GenTableMapper genTableMapper; + + @Autowired + 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 + * + * @return 业务信息 + */ + @Override + public GenTable selectGenTableById (Long id) { +>>>>>>> 813460c (1..) GenTable genTable = genTableMapper.selectGenTableById(id); setTableFromOptions(genTable); return genTable; @@ -73,11 +120,19 @@ public class GenTableServiceImpl implements IGenTableService * 查询业务列表 * * @param genTable 业务信息 +<<<<<<< HEAD * @return 业务集合 */ @Override public List selectGenTableList(GenTable genTable) { +======= + * + * @return 业务集合 + */ + @Override + public List selectGenTableList (GenTable genTable) { +>>>>>>> 813460c (1..) return genTableMapper.selectGenTableList(genTable); } @@ -85,11 +140,19 @@ public class GenTableServiceImpl implements IGenTableService * 查询据库列表 * * @param genTable 业务信息 +<<<<<<< HEAD * @return 数据库表集合 */ @Override public List selectDbTableList(GenTable genTable) { +======= + * + * @return 数据库表集合 + */ + @Override + public List selectDbTableList (GenTable genTable) { +>>>>>>> 813460c (1..) return genTableMapper.selectDbTableList(genTable); } @@ -97,6 +160,7 @@ public class GenTableServiceImpl implements IGenTableService * 查询据库列表 * * @param tableNames 表名称组 +<<<<<<< HEAD * @param dbName * @return 数据库表集合 */ @@ -104,6 +168,14 @@ public class GenTableServiceImpl implements IGenTableService public List selectDbTableListByNames(String[] tableNames, String dbName) { return genTableMapper.selectDbTableListByNames(tableNames,dbName); +======= + * + * @return 数据库表集合 + */ + @Override + public List selectDbTableListByNames (String[] tableNames) { + return genTableMapper.selectDbTableListByNames(tableNames); +>>>>>>> 813460c (1..) } /** @@ -112,8 +184,12 @@ public class GenTableServiceImpl implements IGenTableService * @return 表信息集合 */ @Override +<<<<<<< HEAD public List selectGenTableAll() { +======= + public List selectGenTableAll () { +>>>>>>> 813460c (1..) return genTableMapper.selectGenTableAll(); } @@ -121,10 +197,15 @@ public class GenTableServiceImpl implements IGenTableService * 修改业务 * * @param genTable 业务信息 +<<<<<<< HEAD +======= + * +>>>>>>> 813460c (1..) * @return 结果 */ @Override @Transactional(rollbackFor = Exception.class) +<<<<<<< HEAD public void updateGenTable(GenTable genTable) { String options = JSON.toJSONString(genTable.getParams()); @@ -134,6 +215,14 @@ public class GenTableServiceImpl implements IGenTableService { for (GenTableColumn cenTableColumn : genTable.getColumns()) { +======= + public void updateGenTable (GenTable genTable) { + String options = JSON.toJSONString(genTable.getParams()); + genTable.setOptions(options); + int row = genTableMapper.updateGenTable(genTable); + if (row > 0) { + for (GenTableColumn cenTableColumn : genTable.getColumns()) { +>>>>>>> 813460c (1..) genTableColumnMapper.updateGenTableColumn(cenTableColumn); } } @@ -143,12 +232,20 @@ public class GenTableServiceImpl implements IGenTableService * 删除业务对象 * * @param tableIds 需要删除的数据ID +<<<<<<< HEAD +======= + * +>>>>>>> 813460c (1..) * @return 结果 */ @Override @Transactional(rollbackFor = Exception.class) +<<<<<<< HEAD public void deleteGenTableByIds(Long[] tableIds) { +======= + public void deleteGenTableByIds (Long[] tableIds) { +>>>>>>> 813460c (1..) genTableMapper.deleteGenTableByIds(tableIds); genTableColumnMapper.deleteGenTableColumnByIds(tableIds); } @@ -160,6 +257,7 @@ public class GenTableServiceImpl implements IGenTableService */ @Override @Transactional(rollbackFor = Exception.class) +<<<<<<< HEAD public void importGenTable(List tableList) { String operName = SecurityUtils.getUsername(); @@ -177,14 +275,31 @@ public class GenTableServiceImpl implements IGenTableService List genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName, dbName); for (GenTableColumn column : genTableColumns) { +======= + public void importGenTable (List tableList) { + String operName = SecurityUtils.getUsername(); + try { + for (GenTable table : tableList) { + String tableName = table.getTableName(); + GenUtils.initTable(table, operName); + int row = genTableMapper.insertGenTable(table); + if (row > 0) { + // 保存列信息 + List genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); + for (GenTableColumn column : genTableColumns) { +>>>>>>> 813460c (1..) GenUtils.initColumnField(column, table); genTableColumnMapper.insertGenTableColumn(column); } } } +<<<<<<< HEAD } catch (Exception e) { +======= + } catch (Exception e) { +>>>>>>> 813460c (1..) throw new ServiceException("导入失败:" + e.getMessage()); } } @@ -193,11 +308,19 @@ public class GenTableServiceImpl implements IGenTableService * 预览代码 * * @param tableId 表编号 +<<<<<<< HEAD * @return 预览数据列表 */ @Override public Map previewCode(Long tableId) { +======= + * + * @return 预览数据列表 + */ + @Override + public Map previewCode (Long tableId) { +>>>>>>> 813460c (1..) Map dataMap = new LinkedHashMap<>(); // 查询表信息 GenTable table = genTableMapper.selectGenTableById(tableId); @@ -211,8 +334,12 @@ public class GenTableServiceImpl implements IGenTableService // 获取模板列表 List templates = VelocityUtils.getTemplateList(table.getTplCategory()); +<<<<<<< HEAD for (String template : templates) { +======= + for (String template : templates) { +>>>>>>> 813460c (1..) // 渲染模板 StringWriter sw = new StringWriter(); Template tpl = Velocity.getTemplate(template, Constants.UTF8); @@ -226,11 +353,19 @@ public class GenTableServiceImpl implements IGenTableService * 生成代码(下载方式) * * @param tableName 表名称 +<<<<<<< HEAD * @return 数据 */ @Override public byte[] downloadCode(String tableName) { +======= + * + * @return 数据 + */ + @Override + public byte[] downloadCode (String tableName) { +>>>>>>> 813460c (1..) ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ZipOutputStream zip = new ZipOutputStream(outputStream); generatorCode(tableName, zip); @@ -244,8 +379,12 @@ public class GenTableServiceImpl implements IGenTableService * @param tableName 表名称 */ @Override +<<<<<<< HEAD public void generatorCode(String tableName) { +======= + public void generatorCode (String tableName) { +>>>>>>> 813460c (1..) // 查询表信息 GenTable table = genTableMapper.selectGenTableByName(tableName); // 设置主子表信息 @@ -259,14 +398,20 @@ public class GenTableServiceImpl implements IGenTableService // 获取模板列表 List templates = VelocityUtils.getTemplateList(table.getTplCategory()); +<<<<<<< HEAD for (String template : templates) { if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) { +======= + for (String template : templates) { + if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) { +>>>>>>> 813460c (1..) // 渲染模板 StringWriter sw = new StringWriter(); Template tpl = Velocity.getTemplate(template, Constants.UTF8); tpl.merge(context, sw); +<<<<<<< HEAD try { String path = getGenPath(table, template); @@ -274,6 +419,12 @@ public class GenTableServiceImpl implements IGenTableService } catch (IOException e) { +======= + try { + String path = getGenPath(table, template); + FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8); + } catch (IOException e) { +>>>>>>> 813460c (1..) throw new ServiceException("渲染模板失败,表名:" + table.getTableName()); } } @@ -284,54 +435,85 @@ public class GenTableServiceImpl implements IGenTableService * 同步数据库 * * @param tableName 表名称 +<<<<<<< HEAD * @param dbName */ @Override @Transactional(rollbackFor = Exception.class) public void synchDb(String tableName, String dbName) { +======= + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void synchDb (String tableName) { +>>>>>>> 813460c (1..) GenTable table = genTableMapper.selectGenTableByName(tableName); List tableColumns = table.getColumns(); Map tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity())); +<<<<<<< HEAD List dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName, dbName); if (StringUtils.isEmpty(dbTableColumns)) { +======= + List dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName); + if (StringUtils.isEmpty(dbTableColumns)) { +>>>>>>> 813460c (1..) throw new ServiceException("同步数据失败,原表结构不存在"); } List dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList()); dbTableColumns.forEach(column -> { GenUtils.initColumnField(column, table); +<<<<<<< HEAD if (tableColumnMap.containsKey(column.getColumnName())) { GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName()); column.setColumnId(prevColumn.getColumnId()); if (column.isList()) { +======= + if (tableColumnMap.containsKey(column.getColumnName())) { + GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName()); + column.setColumnId(prevColumn.getColumnId()); + if (column.isList()) { +>>>>>>> 813460c (1..) // 如果是列表,继续保留查询方式/字典类型选项 column.setDictType(prevColumn.getDictType()); column.setQueryType(prevColumn.getQueryType()); } if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk() && (column.isInsert() || column.isEdit()) +<<<<<<< HEAD && ((column.isUsableColumn()) || (!column.isSuperColumn()))) { +======= + && ((column.isUsableColumn()) || (!column.isSuperColumn()))) { +>>>>>>> 813460c (1..) // 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项 column.setIsRequired(prevColumn.getIsRequired()); column.setHtmlType(prevColumn.getHtmlType()); } genTableColumnMapper.updateGenTableColumn(column); +<<<<<<< HEAD } else { +======= + } else { +>>>>>>> 813460c (1..) genTableColumnMapper.insertGenTableColumn(column); } }); List delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList()); +<<<<<<< HEAD if (StringUtils.isNotEmpty(delColumns)) { +======= + if (StringUtils.isNotEmpty(delColumns)) { +>>>>>>> 813460c (1..) genTableColumnMapper.deleteGenTableColumns(delColumns); } } @@ -340,6 +522,7 @@ public class GenTableServiceImpl implements IGenTableService * 批量生成代码(下载方式) * * @param tableNames 表数组 +<<<<<<< HEAD * @return 数据 */ @Override @@ -349,6 +532,16 @@ public class GenTableServiceImpl implements IGenTableService ZipOutputStream zip = new ZipOutputStream(outputStream); for (String tableName : tableNames) { +======= + * + * @return 数据 + */ + @Override + public byte[] downloadCode (String[] tableNames) { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ZipOutputStream zip = new ZipOutputStream(outputStream); + for (String tableName : tableNames) { +>>>>>>> 813460c (1..) generatorCode(tableName, zip); } IOUtils.closeQuietly(zip); @@ -358,8 +551,12 @@ public class GenTableServiceImpl implements IGenTableService /** * 查询表信息并生成代码 */ +<<<<<<< HEAD private void generatorCode(String tableName, ZipOutputStream zip) { +======= + private void generatorCode (String tableName, ZipOutputStream zip) { +>>>>>>> 813460c (1..) // 查询表信息 GenTable table = genTableMapper.selectGenTableByName(tableName); // 设置主子表信息 @@ -373,23 +570,35 @@ public class GenTableServiceImpl implements IGenTableService // 获取模板列表 List templates = VelocityUtils.getTemplateList(table.getTplCategory()); +<<<<<<< HEAD for (String template : templates) { +======= + for (String template : templates) { +>>>>>>> 813460c (1..) // 渲染模板 StringWriter sw = new StringWriter(); Template tpl = Velocity.getTemplate(template, Constants.UTF8); tpl.merge(context, sw); +<<<<<<< HEAD try { +======= + try { +>>>>>>> 813460c (1..) // 添加到zip zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table))); IOUtils.write(sw.toString(), zip, Constants.UTF8); IOUtils.closeQuietly(sw); zip.flush(); zip.closeEntry(); +<<<<<<< HEAD } catch (IOException e) { +======= + } catch (IOException e) { +>>>>>>> 813460c (1..) log.error("渲染模板失败,表名:" + table.getTableName(), e); } } @@ -401,6 +610,7 @@ public class GenTableServiceImpl implements IGenTableService * @param genTable 业务信息 */ @Override +<<<<<<< HEAD public void validateEdit(GenTable genTable) { if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) @@ -427,12 +637,29 @@ public class GenTableServiceImpl implements IGenTableService } else if (StringUtils.isEmpty(genTable.getSubTableFkName())) { +======= + public void validateEdit (GenTable genTable) { + if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) { + String options = JSON.toJSONString(genTable.getParams()); + JSONObject paramsObj = JSON.parseObject(options); + if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) { + throw new ServiceException("树编码字段不能为空"); + } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) { + throw new ServiceException("树父编码字段不能为空"); + } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) { + throw new ServiceException("树名称字段不能为空"); + } else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) { + if (StringUtils.isEmpty(genTable.getSubTableName())) { + throw new ServiceException("关联子表的表名不能为空"); + } else if (StringUtils.isEmpty(genTable.getSubTableFkName())) { +>>>>>>> 813460c (1..) throw new ServiceException("子表关联的外键名不能为空"); } } } } +<<<<<<< HEAD @Override public List selDbNameAll() { return genTableMapper.selDbNameAll(); @@ -444,21 +671,30 @@ public class GenTableServiceImpl implements IGenTableService } +======= +>>>>>>> 813460c (1..) /** * 设置主键列信息 * * @param table 业务表信息 */ +<<<<<<< HEAD public void setPkColumn(GenTable table) { for (GenTableColumn column : table.getColumns()) { if (column.isPk()) { +======= + public void setPkColumn (GenTable table) { + for (GenTableColumn column : table.getColumns()) { + if (column.isPk()) { +>>>>>>> 813460c (1..) table.setPkColumn(column); break; } } +<<<<<<< HEAD if (StringUtils.isNull(table.getPkColumn())) { table.setPkColumn(table.getColumns().get(0)); @@ -469,12 +705,24 @@ public class GenTableServiceImpl implements IGenTableService { if (column.isPk()) { +======= + if (StringUtils.isNull(table.getPkColumn())) { + table.setPkColumn(table.getColumns().get(0)); + } + if (GenConstants.TPL_SUB.equals(table.getTplCategory())) { + for (GenTableColumn column : table.getSubTable().getColumns()) { + if (column.isPk()) { +>>>>>>> 813460c (1..) table.getSubTable().setPkColumn(column); break; } } +<<<<<<< HEAD if (StringUtils.isNull(table.getSubTable().getPkColumn())) { +======= + if (StringUtils.isNull(table.getSubTable().getPkColumn())) { +>>>>>>> 813460c (1..) table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0)); } } @@ -485,11 +733,17 @@ public class GenTableServiceImpl implements IGenTableService * * @param table 业务表信息 */ +<<<<<<< HEAD public void setSubTable(GenTable table) { String subTableName = table.getSubTableName(); if (StringUtils.isNotEmpty(subTableName)) { +======= + public void setSubTable (GenTable table) { + String subTableName = table.getSubTableName(); + if (StringUtils.isNotEmpty(subTableName)) { +>>>>>>> 813460c (1..) table.setSubTable(genTableMapper.selectGenTableByName(subTableName)); } } @@ -499,11 +753,17 @@ public class GenTableServiceImpl implements IGenTableService * * @param genTable 设置后的生成对象 */ +<<<<<<< HEAD public void setTableFromOptions(GenTable genTable) { JSONObject paramsObj = JSON.parseObject(genTable.getOptions()); if (StringUtils.isNotNull(paramsObj)) { +======= + public void setTableFromOptions (GenTable genTable) { + JSONObject paramsObj = JSON.parseObject(genTable.getOptions()); + if (StringUtils.isNotNull(paramsObj)) { +>>>>>>> 813460c (1..) String treeCode = paramsObj.getString(GenConstants.TREE_CODE); String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE); String treeName = paramsObj.getString(GenConstants.TREE_NAME); @@ -517,6 +777,7 @@ public class GenTableServiceImpl implements IGenTableService genTable.setParentMenuName(parentMenuName); } } +<<<<<<< HEAD /** * 获取代码生成地址 @@ -534,4 +795,6 @@ public class GenTableServiceImpl implements IGenTableService } return genPath + File.separator + VelocityUtils.getFileName(template, table); } +======= +>>>>>>> 813460c (1..) } diff --git a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableColumnService.java b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableColumnService.java index e6d4d55..3b75a7e 100644 --- a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableColumnService.java +++ b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableColumnService.java @@ -7,41 +7,75 @@ import java.util.List; /** * 业务字段 服务层 * +<<<<<<< HEAD * @author ruoyi */ public interface IGenTableColumnService { +======= + * @author muyu + */ +public interface IGenTableColumnService { +>>>>>>> 813460c (1..) /** * 查询业务字段列表 * * @param tableId 业务字段编号 +<<<<<<< HEAD * @return 业务字段集合 */ public List selectGenTableColumnListByTableId(Long tableId); +======= + * + * @return 业务字段集合 + */ + List selectGenTableColumnListByTableId (Long tableId); +>>>>>>> 813460c (1..) /** * 新增业务字段 * * @param genTableColumn 业务字段信息 +<<<<<<< HEAD * @return 结果 */ public int insertGenTableColumn(GenTableColumn genTableColumn); +======= + * + * @return 结果 + */ + int insertGenTableColumn (GenTableColumn genTableColumn); +>>>>>>> 813460c (1..) /** * 修改业务字段 * * @param genTableColumn 业务字段信息 +<<<<<<< HEAD * @return 结果 */ public int updateGenTableColumn(GenTableColumn genTableColumn); +======= + * + * @return 结果 + */ + int updateGenTableColumn (GenTableColumn genTableColumn); +>>>>>>> 813460c (1..) /** * 删除业务字段信息 * * @param ids 需要删除的数据ID +<<<<<<< HEAD * @return 结果 */ public int deleteGenTableColumnByIds(String ids); List selectDbTableColumnsByName(String table, String dbName); +======= + * + * @return 结果 + */ + int deleteGenTableColumnByIds (String ids); +>>>>>>> 813460c (1..) } diff --git a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableService.java b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableService.java index f79d5e8..d7cec23 100644 --- a/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableService.java +++ b/cloud-modules/cloud-modules-gen/src/main/java/com/muyu/gen/service/IGenTableService.java @@ -1,7 +1,10 @@ package com.muyu.gen.service; import com.muyu.gen.domain.GenTable; +<<<<<<< HEAD import com.muyu.gen.domain.GenTableResp; +======= +>>>>>>> 813460c (1..) import java.util.List; import java.util.Map; @@ -9,121 +12,214 @@ import java.util.Map; /** * 业务 服务层 * +<<<<<<< HEAD * @author ruoyi */ public interface IGenTableService { +======= + * @author muyu + */ +public interface IGenTableService { +>>>>>>> 813460c (1..) /** * 查询业务列表 * * @param genTable 业务信息 +<<<<<<< HEAD * @return 业务集合 */ public List selectGenTableList(GenTable genTable); +======= + * + * @return 业务集合 + */ + List selectGenTableList (GenTable genTable); +>>>>>>> 813460c (1..) /** * 查询据库列表 * * @param genTable 业务信息 +<<<<<<< HEAD * @return 数据库表集合 */ public List selectDbTableList(GenTable genTable); +======= + * + * @return 数据库表集合 + */ + List selectDbTableList (GenTable genTable); +>>>>>>> 813460c (1..) /** * 查询据库列表 * * @param tableNames 表名称组 +<<<<<<< HEAD * @param dbName * @return 数据库表集合 */ public List selectDbTableListByNames(String[] tableNames, String dbName); +======= + * + * @return 数据库表集合 + */ + List selectDbTableListByNames (String[] tableNames); +>>>>>>> 813460c (1..) /** * 查询所有表信息 * * @return 表信息集合 */ +<<<<<<< HEAD public List selectGenTableAll(); +======= + List selectGenTableAll (); +>>>>>>> 813460c (1..) /** * 查询业务信息 * * @param id 业务ID +<<<<<<< HEAD * @return 业务信息 */ public GenTable selectGenTableById(Long id); +======= + * + * @return 业务信息 + */ + GenTable selectGenTableById (Long id); +>>>>>>> 813460c (1..) /** * 修改业务 * * @param genTable 业务信息 +<<<<<<< HEAD * @return 结果 */ public void updateGenTable(GenTable genTable); +======= + * + * @return 结果 + */ + void updateGenTable (GenTable genTable); +>>>>>>> 813460c (1..) /** * 删除业务信息 * * @param tableIds 需要删除的表数据ID +<<<<<<< HEAD * @return 结果 */ public void deleteGenTableByIds(Long[] tableIds); +======= + * + * @return 结果 + */ + void deleteGenTableByIds (Long[] tableIds); +>>>>>>> 813460c (1..) /** * 导入表结构 * * @param tableList 导入表列表 */ +<<<<<<< HEAD public void importGenTable(List tableList); +======= + void importGenTable (List tableList); +>>>>>>> 813460c (1..) /** * 预览代码 * * @param tableId 表编号 +<<<<<<< HEAD * @return 预览数据列表 */ public Map previewCode(Long tableId); +======= + * + * @return 预览数据列表 + */ + Map previewCode (Long tableId); +>>>>>>> 813460c (1..) /** * 生成代码(下载方式) * * @param tableName 表名称 +<<<<<<< HEAD * @return 数据 */ public byte[] downloadCode(String tableName); +======= + * + * @return 数据 + */ + byte[] downloadCode (String tableName); +>>>>>>> 813460c (1..) /** * 生成代码(自定义路径) * * @param tableName 表名称 +<<<<<<< HEAD * @return 数据 */ public void generatorCode(String tableName); +======= + * + * @return 数据 + */ + void generatorCode (String tableName); +>>>>>>> 813460c (1..) /** * 同步数据库 * * @param tableName 表名称 +<<<<<<< HEAD * @param dbName */ public void synchDb(String tableName, String dbName); +======= + */ + void synchDb (String tableName); +>>>>>>> 813460c (1..) /** * 批量生成代码(下载方式) * * @param tableNames 表数组 +<<<<<<< HEAD * @return 数据 */ public byte[] downloadCode(String[] tableNames); +======= + * + * @return 数据 + */ + byte[] downloadCode (String[] tableNames); +>>>>>>> 813460c (1..) /** * 修改保存参数校验 * * @param genTable 业务信息 */ +<<<<<<< HEAD public void validateEdit(GenTable genTable); List selDbNameAll(); List selectDbTableListAll(); +======= + void validateEdit (GenTable genTable); +>>>>>>> 813460c (1..) } diff --git a/cloud-modules/cloud-modules-gen/src/main/resources/bootstrap.yml b/cloud-modules/cloud-modules-gen/src/main/resources/bootstrap.yml index 47acae2..907283d 100644 --- a/cloud-modules/cloud-modules-gen/src/main/resources/bootstrap.yml +++ b/cloud-modules/cloud-modules-gen/src/main/resources/bootstrap.yml @@ -1,12 +1,17 @@ # Tomcat server: +<<<<<<< HEAD port: 9709 +======= + port: 9202 +>>>>>>> 813460c (1..) # nacos线上地址 nacos: addr: 47.116.173.119:8848 user-name: nacos password: nacos +<<<<<<< HEAD namespace: one-saas # SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all # Spring @@ -15,6 +20,12 @@ spring: deserialization: trust: all: true +======= + namespace: one + +# Spring +spring: +>>>>>>> 813460c (1..) main: allow-bean-definition-overriding: true application: @@ -53,8 +64,11 @@ spring: - application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} # xxl-job 配置文件 - application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +<<<<<<< HEAD # rabbit 配置文件 - application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} logging: level: com.muyu.system.mapper: DEBUG +======= +>>>>>>> 813460c (1..) diff --git a/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableColumnMapper.xml b/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableColumnMapper.xml index ea0616b..d70e934 100644 --- a/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableColumnMapper.xml +++ b/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableColumnMapper.xml @@ -1,5 +1,6 @@ @@ -31,6 +32,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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 +======= + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 +>>>>>>> 813460c (1..) + + + insert into gen_table_column ( + 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 + )values( + #{tableId}, + #{columnName}, + #{columnComment}, + #{columnType}, + #{javaType}, + #{javaField}, + #{isPk}, + #{isIncrement}, + #{isRequired}, + #{isInsert}, + #{isEdit}, + #{isList}, + #{isQuery}, + #{queryType}, + #{htmlType}, + #{dictType}, + #{sort}, + #{createBy}, + sysdate() + ) +>>>>>>> 813460c (1..) @@ -113,6 +227,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +<<<<<<< HEAD delete from gen_table_column where table_id in ( #{tableId} @@ -127,6 +242,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item.columnId} ) +======= + delete from gen_table_column where table_id in + + #{tableId} + + + + + delete from gen_table_column where column_id in + + #{item.columnId} + +>>>>>>> 813460c (1..) diff --git a/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableMapper.xml b/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableMapper.xml index ba9b0cf..561ab48 100644 --- a/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableMapper.xml +++ b/cloud-modules/cloud-modules-gen/src/main/resources/mapper/generator/GenTableMapper.xml @@ -1,5 +1,6 @@ @@ -197,12 +198,298 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{createBy}, sysdate() ) +======= + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + + + + + + + + + + + + + + + + insert into gen_table ( + table_name, + table_comment, + class_name, + tpl_category, + package_name, + module_name, + business_name, + function_name, + function_author, + gen_type, + gen_path, + remark, + create_by, + create_time + )values( + #{tableName}, + #{tableComment}, + #{className}, + #{tplCategory}, + #{packageName}, + #{moduleName}, + #{businessName}, + #{functionName}, + #{functionAuthor}, + #{genType}, + #{genPath}, + #{remark}, + #{createBy}, + sysdate() + ) +>>>>>>> 813460c (1..) update gen_table +<<<<<<< HEAD db_name = #{dbName}, +======= +>>>>>>> 813460c (1..) table_name = #{tableName}, table_comment = #{tableComment}, sub_table_name = #{subTableName}, @@ -211,7 +498,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" function_author = #{functionAuthor}, gen_type = #{genType}, gen_path = #{genPath}, +<<<<<<< HEAD tpl_category = #{tplCategory}, package_name = #{packageName}, +======= + tpl_category = #{tplCategory}, + package_name = #{packageName}, +>>>>>>> 813460c (1..) module_name = #{moduleName}, business_name = #{businessName}, function_name = #{functionName}, @@ -224,11 +516,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +<<<<<<< HEAD delete from gen_table where table_id in ( #{tableId} ) +======= + delete from gen_table where table_id in + + #{tableId} + +>>>>>>> 813460c (1..) diff --git a/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/controller.java.vm b/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/controller.java.vm index c62cc8b..4413508 100644 --- a/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/controller.java.vm +++ b/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/controller.java.vm @@ -1,9 +1,16 @@ package ${packageName}.controller; +<<<<<<< HEAD import java.util.Arrays; import java.util.List; import jakarta.servlet.http.HttpServletResponse; import javax.annotation.Resource; +======= +import java.util.List; +import java.io.IOException; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -12,14 +19,22 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +<<<<<<< HEAD +======= +import com.muyu.common.log.annotation.Log; +import com.muyu.common.log.enums.BusinessType; +>>>>>>> 813460c (1..) import com.muyu.common.security.annotation.RequiresPermissions; import ${packageName}.domain.${ClassName}; import ${packageName}.service.I${ClassName}Service; import com.muyu.common.core.web.controller.BaseController; import com.muyu.common.core.domain.Result; import com.muyu.common.core.utils.poi.ExcelUtil; +<<<<<<< HEAD import com.muyu.common.security.utils.SecurityUtils; import org.springframework.validation.annotation.Validated; +======= +>>>>>>> 813460c (1..) #if($table.crud || $table.sub) import com.muyu.common.core.web.page.TableDataInfo; #elseif($table.tree) @@ -35,7 +50,11 @@ import com.muyu.common.core.web.page.TableDataInfo; @RequestMapping("/${businessName}") public class ${ClassName}Controller extends BaseController { +<<<<<<< HEAD @Resource +======= + @Autowired +>>>>>>> 813460c (1..) private I${ClassName}Service ${className}Service; /** @@ -44,14 +63,22 @@ public class ${ClassName}Controller extends BaseController @RequiresPermissions("${permissionPrefix}:list") @GetMapping("/list") #if($table.crud || $table.sub) +<<<<<<< HEAD public Result> list(${ClassName} ${className}) +======= + public Result list(${ClassName} ${className}) +>>>>>>> 813460c (1..) { startPage(); List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); return getDataTable(list); } #elseif($table.tree) +<<<<<<< HEAD public Result<${ClassName}> list(${ClassName} ${className}) +======= + public Result list(${ClassName} ${className}) +>>>>>>> 813460c (1..) { List<${ClassName}> list = ${className}Service.select${ClassName}List(${className}); return success(list); @@ -62,6 +89,10 @@ public class ${ClassName}Controller extends BaseController * 导出${functionName}列表 */ @RequiresPermissions("${permissionPrefix}:export") +<<<<<<< HEAD +======= + @Log(title = "${functionName}", businessType = BusinessType.EXPORT) +>>>>>>> 813460c (1..) @PostMapping("/export") public void export(HttpServletResponse response, ${ClassName} ${className}) { @@ -75,7 +106,11 @@ public class ${ClassName}Controller extends BaseController */ @RequiresPermissions("${permissionPrefix}:query") @GetMapping(value = "/{${pkColumn.javaField}}") +<<<<<<< HEAD public Result> getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) +======= + public Result getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) +>>>>>>> 813460c (1..) { return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField})); } @@ -84,6 +119,7 @@ public class ${ClassName}Controller extends BaseController * 新增${functionName} */ @RequiresPermissions("${permissionPrefix}:add") +<<<<<<< HEAD @PostMapping public Result add( @Validated @RequestBody ${ClassName} ${className}) @@ -93,12 +129,20 @@ public class ${ClassName}Controller extends BaseController } ${className}.setCreateBy(SecurityUtils.getUsername()); return toAjax(${className}Service.save(${className})); +======= + @Log(title = "${functionName}", businessType = BusinessType.INSERT) + @PostMapping + public Result add(@RequestBody ${ClassName} ${className}) + { + return toAjax(${className}Service.insert${ClassName}(${className})); +>>>>>>> 813460c (1..) } /** * 修改${functionName} */ @RequiresPermissions("${permissionPrefix}:edit") +<<<<<<< HEAD @PutMapping public Result edit( @Validated @RequestBody ${ClassName} ${className}) @@ -108,16 +152,31 @@ public class ${ClassName}Controller extends BaseController } ${className}.setUpdateBy(SecurityUtils.getUsername()); return toAjax(${className}Service.updateById(${className})); +======= + @Log(title = "${functionName}", businessType = BusinessType.UPDATE) + @PutMapping + public Result edit(@RequestBody ${ClassName} ${className}) + { + return toAjax(${className}Service.update${ClassName}(${className})); +>>>>>>> 813460c (1..) } /** * 删除${functionName} */ @RequiresPermissions("${permissionPrefix}:remove") +<<<<<<< HEAD @DeleteMapping("/{${pkColumn.javaField}s}") public Result remove(@PathVariable("${pkColumn.javaField}s") ${pkColumn.javaType}[] ${pkColumn.javaField}s) { ${className}Service.removeBatchByIds(Arrays.asList(${pkColumn.javaField}s)); return success(); +======= + @Log(title = "${functionName}", businessType = BusinessType.DELETE) + @DeleteMapping("/{${pkColumn.javaField}s}") + public Result remove(@PathVariable("${pkColumn.javaField}s") ${pkColumn.javaType}[] ${pkColumn.javaField}s) + { + return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s)); +>>>>>>> 813460c (1..) } } diff --git a/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/domain.java.vm b/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/domain.java.vm index 4c89918..d57515d 100644 --- a/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/domain.java.vm +++ b/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/domain.java.vm @@ -9,6 +9,7 @@ import com.muyu.common.core.web.domain.BaseEntity; #elseif($table.tree) import com.muyu.common.core.web.domain.TreeEntity; #end +<<<<<<< HEAD import lombok.*; import lombok.experimental.SuperBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -16,6 +17,8 @@ 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; +======= +>>>>>>> 813460c (1..) /** * ${functionName}对象 ${tableName} @@ -23,12 +26,16 @@ import com.baomidou.mybatisplus.annotation.IdType; * @author ${author} * @date ${datetime} */ +<<<<<<< HEAD +======= +>>>>>>> 813460c (1..) #if($table.crud || $table.sub) #set($Entity="BaseEntity") #elseif($table.tree) #set($Entity="TreeEntity") #end +<<<<<<< HEAD @Data @Setter @Getter @@ -37,6 +44,10 @@ import com.baomidou.mybatisplus.annotation.IdType; @AllArgsConstructor @TableName("${tableName}") public class ${ClassName} extends ${Entity}{ +======= +public class ${ClassName} extends ${Entity} +{ +>>>>>>> 813460c (1..) private static final long serialVersionUID = 1L; #foreach ($column in $columns) @@ -58,19 +69,46 @@ public class ${ClassName} extends ${Entity}{ @Excel(name = "${comment}") #end #end +<<<<<<< HEAD #if($column.javaField == $pkColumn.javaField) @TableId( type = IdType.AUTO) #end +======= +>>>>>>> 813460c (1..) private $column.javaType $column.javaField; #end #end +<<<<<<< HEAD +======= +>>>>>>> 813460c (1..) #if($table.sub) /** $table.subTable.functionName信息 */ private List<${subClassName}> ${subclassName}List; #end +<<<<<<< HEAD +======= +#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 +>>>>>>> 813460c (1..) #if($table.sub) public List<${subClassName}> get${subClassName}List() diff --git a/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/mapper.java.vm b/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/mapper.java.vm index e6f420b..03401fb 100644 --- a/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/mapper.java.vm +++ b/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/mapper.java.vm @@ -5,6 +5,7 @@ import ${packageName}.domain.${ClassName}; #if($table.sub) import ${packageName}.domain.${subClassName}; #end +<<<<<<< HEAD import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; @@ -17,4 +18,89 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface ${ClassName}Mapper extends BaseMapper<${ClassName}>{ +======= + +/** + * ${functionName}Mapper接口 + * + * @author ${author} + * @date ${datetime} + */ +public interface ${ClassName}Mapper +{ + /** + * 查询${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 +>>>>>>> 813460c (1..) } diff --git a/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/service.java.vm b/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/service.java.vm index 1a01fae..9369c73 100644 --- a/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/service.java.vm +++ b/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/service.java.vm @@ -2,6 +2,7 @@ package ${packageName}.service; import java.util.List; import ${packageName}.domain.${ClassName}; +<<<<<<< HEAD import com.baomidou.mybatisplus.extension.service.IService; /** @@ -14,6 +15,20 @@ public interface I${ClassName}Service extends IService<${ClassName}> { /** * 精确查询${functionName} * +======= + +/** + * ${functionName}Service接口 + * + * @author ${author} + * @date ${datetime} + */ +public interface I${ClassName}Service +{ + /** + * 查询${functionName} + * +>>>>>>> 813460c (1..) * @param ${pkColumn.javaField} ${functionName}主键 * @return ${functionName} */ @@ -21,17 +36,54 @@ public interface I${ClassName}Service extends IService<${ClassName}> { /** * 查询${functionName}列表 +<<<<<<< HEAD * +======= + * +>>>>>>> 813460c (1..) * @param ${className} ${functionName} * @return ${functionName}集合 */ public List<${ClassName}> select${ClassName}List(${ClassName} ${className}); /** +<<<<<<< HEAD * 判断 ${functionName} id是否唯一 * @param ${className} ${functionName} * @return 结果 */ Boolean checkIdUnique(${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}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}); +>>>>>>> 813460c (1..) } diff --git a/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/serviceImpl.java.vm b/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/serviceImpl.java.vm index 38f1eca..477e814 100644 --- a/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/serviceImpl.java.vm +++ b/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/serviceImpl.java.vm @@ -7,6 +7,10 @@ import com.muyu.common.core.utils.DateUtils; #break #end #end +<<<<<<< HEAD +======= +import org.springframework.beans.factory.annotation.Autowired; +>>>>>>> 813460c (1..) import org.springframework.stereotype.Service; #if($table.sub) import java.util.ArrayList; @@ -17,10 +21,13 @@ import ${packageName}.domain.${subClassName}; import ${packageName}.mapper.${ClassName}Mapper; import ${packageName}.domain.${ClassName}; import ${packageName}.service.I${ClassName}Service; +<<<<<<< HEAD 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; +======= +>>>>>>> 813460c (1..) /** * ${functionName}Service业务层处理 @@ -29,12 +36,22 @@ import org.springframework.util.Assert; * @date ${datetime} */ @Service +<<<<<<< HEAD public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements I${ClassName}Service { /** * 精确查询${functionName} +======= +public class ${ClassName}ServiceImpl implements I${ClassName}Service +{ + @Autowired + private ${ClassName}Mapper ${className}Mapper; + + /** + * 查询${functionName} +>>>>>>> 813460c (1..) * * @param ${pkColumn.javaField} ${functionName}主键 * @return ${functionName} @@ -42,6 +59,7 @@ public class ${ClassName}ServiceImpl @Override public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField}) { +<<<<<<< HEAD LambdaQueryWrapper<${ClassName}> queryWrapper = new LambdaQueryWrapper<>(); Assert.notNull(${pkColumn.javaField}, "${pkColumn.javaField}不可为空"); queryWrapper.eq(${ClassName}::get${pkColumn.capJavaField}, ${pkColumn.javaField}); @@ -49,6 +67,11 @@ public class ${ClassName}ServiceImpl } +======= + return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}); + } + +>>>>>>> 813460c (1..) /** * 查询${functionName}列表 * @@ -58,6 +81,7 @@ public class ${ClassName}ServiceImpl @Override public List<${ClassName}> select${ClassName}List(${ClassName} ${className}) { +<<<<<<< HEAD LambdaQueryWrapper<${ClassName}> queryWrapper = new LambdaQueryWrapper<>(); #foreach($column in $columns) #set($queryType=$column.queryType) @@ -112,4 +136,120 @@ public class ${ClassName}ServiceImpl return this.count(queryWrapper) > 0; } +======= + return ${className}Mapper.select${ClassName}List(${className}); + } + + /** + * 新增${functionName} + * + * @param ${className} ${functionName} + * @return 结果 + */ +#if($table.sub) + @Transactional +#end + @Override + public int insert${ClassName}(${ClassName} ${className}) + { +#foreach ($column in $columns) +#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 +>>>>>>> 813460c (1..) } diff --git a/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/sub-domain.java.vm b/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/sub-domain.java.vm index 61c6273..4dd894e 100644 --- a/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/sub-domain.java.vm +++ b/cloud-modules/cloud-modules-gen/src/main/resources/vm/java/sub-domain.java.vm @@ -17,7 +17,12 @@ import com.muyu.common.core.web.domain.BaseEntity; @NoArgsConstructor @AllArgsConstructor @EqualsAndHashCode(callSuper = true) +<<<<<<< HEAD public class ${subClassName} extends BaseEntity { +======= +public class ${subClassName} extends BaseEntity +{ +>>>>>>> 813460c (1..) private static final long serialVersionUID = 1L; #foreach ($column in $subTable.columns) diff --git a/cloud-modules/cloud-modules-gen/src/main/resources/vm/vue/index.vue.vm b/cloud-modules/cloud-modules-gen/src/main/resources/vm/vue/index.vue.vm index cf9b3b0..de4c302 100644 --- a/cloud-modules/cloud-modules-gen/src/main/resources/vm/vue/index.vue.vm +++ b/cloud-modules/cloud-modules-gen/src/main/resources/vm/vue/index.vue.vm @@ -170,7 +170,11 @@ +<<<<<<< HEAD +======= + +>>>>>>> 813460c (1..)