saas初始化

dev.saas.customer
面包骑士 2024-09-21 19:29:37 +08:00
parent 27f393b37d
commit 11b8427ddb
95 changed files with 2637 additions and 997 deletions

View File

@ -34,7 +34,7 @@ public class TokenController {
@PostMapping("login")
public Result<?> login (@RequestBody LoginBody form) {
// 用户登录
LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
LoginUser userInfo = sysLoginService.login(form);
// 获取登录token
return Result.success(tokenService.createToken(userInfo));
}

View File

@ -1,11 +1,16 @@
package com.muyu.auth.form;
import lombok.Data;
/**
*
*
* @author muyu
*/
@Data
public class LoginBody {
private String firmCode;
/**
*
*/
@ -15,20 +20,4 @@ public class LoginBody {
*
*/
private String password;
public String getUsername () {
return username;
}
public void setUsername (String username) {
this.username = username;
}
public String getPassword () {
return password;
}
public void setPassword (String password) {
this.password = password;
}
}

View File

@ -1,5 +1,6 @@
package com.muyu.auth.service;
import com.muyu.auth.form.LoginBody;
import com.muyu.common.core.constant.CacheConstants;
import com.muyu.common.core.constant.Constants;
import com.muyu.common.core.constant.SecurityConstants;
@ -40,9 +41,12 @@ public class SysLoginService {
/**
*
*/
public LoginUser login (String username, String password) {
public LoginUser login (LoginBody form) {
String firmCode = form.getFirmCode();
String username = form.getUsername();
String password = form.getPassword();
// 用户名或密码为空 错误
if (StringUtils.isAnyBlank(username, password)) {
if (StringUtils.isAnyBlank(firmCode, username, password)) {
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
throw new ServiceException("用户/密码必须填写");
}
@ -65,7 +69,7 @@ public class SysLoginService {
throw new ServiceException("很遗憾访问IP已被列入系统黑名单");
}
// 查询用户信息
Result<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
Result<LoginUser> userResult = remoteUserService.getUserInfo(firmCode, username, SecurityConstants.INNER);
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");

View File

@ -4,10 +4,10 @@ server:
# nacos线上地址
nacos:
addr: 106.54.193.225:8848
addr: 47.116.173.119:8848
user-name: nacos
password: nacos
namespace: one
namespace: one-saas
# Spring
spring:
application:

View File

@ -45,4 +45,9 @@ public class SecurityConstants {
*
*/
public static final String ROLE_PERMISSION = "role_permission";
/**
* SAASkey
*/
public static final String SAAS_KEY = "ent-code";
}

View File

@ -20,4 +20,11 @@ public class ServiceNameConstants {
* serviceid
*/
public static final String FILE_SERVICE = "cloud-file";
/**
*
*/
public static final String SMART_SERVICE = "cloud-smart-car";
public static final String ENT_SERVICE = "cloud-ent";
}

View File

@ -80,4 +80,12 @@ public class SecurityContextHolder {
public static void remove () {
THREAD_LOCAL.remove();
}
public static String getSaasKey() {
return get(SecurityConstants.SAAS_KEY);
}
public static void setSaasKey(String saasKey) {
set(SecurityConstants.SAAS_KEY,saasKey);
}
}

View File

@ -5,7 +5,7 @@ package com.muyu.common.core.exception;
*
* @author muyu
*/
public final class ServiceException extends RuntimeException {
public class ServiceException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
@ -21,7 +21,7 @@ public final class ServiceException extends RuntimeException {
/**
*
* <p>
* {@link CommonResult#getDetailMessage()}
* {CommonResult#getDetailMessage()}
*/
private String detailMessage;

View File

@ -162,4 +162,15 @@ public class JwtUtils {
public static String getValue (Claims claims, String key) {
return Convert.toStr(claims.get(key), "");
}
/**
* SAASKey
*
* @param claims
*
* @return saas_key
*/
public static String getSaasKey(Claims claims) {
return getValue(claims, SecurityConstants.SAAS_KEY);
}
}

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>cloud-common</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>cloud-common-saas</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 多数据源依赖 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-datasource</artifactId>
</dependency>
<!-- 鉴权依赖 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-security</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,120 @@
package com.muyu.cloud.common.many.datasource;
import cn.hutool.json.JSONObject;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
import com.muyu.cloud.common.many.datasource.constents.DatasourceContent;
import com.muyu.cloud.common.saas.domain.model.EntInfo;
import com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory;
import com.muyu.cloud.common.many.datasource.domain.model.DataSourceInfo;
import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
import com.muyu.cloud.common.saas.exception.SaaSException;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.SpringUtils;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.system.domain.SysEnt;
import com.muyu.common.system.domain.SysFirmUser;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.remote.RemoteEntService;
import com.muyu.common.system.remote.RemoteUserService;
import lombok.extern.log4j.Log4j2;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author: DongZeLiang
* @date: 2024/6/3
* @Description:
* @Version: 1.0
*/
@Log4j2
@AutoConfiguration(before = {MybatisPlusAutoConfiguration.class, MybatisAutoConfiguration.class})
@Component
public class ManyDataSource implements ApplicationRunner{
private List<EntInfo> dataSourceInfoList(){
RemoteUserService remoteUserService = SpringUtils.getBean(RemoteUserService.class);
Result<List<SysEnt>> listResult = remoteUserService.list(new SysEnt());
if (listResult==null){
throw new SaaSException("saas远调数据源错误");
}
List<SysEnt> data = listResult.getData();
System.out.println(data);
if (listResult.getCode() == Result.SUCCESS && data !=null){
List<EntInfo> list = new ArrayList<>();
for (SysEnt row : data) {
list.add(
EntInfo.builder()
.entCode(row.getEntCode())
.dbName(row.getDbName())
.ip(row.getIp())
.port(row.getPort())
.userName(row.getUserName())
.password(row.getPassword())
.build()
);
}
return list;
}else {
log.error("远调数据源错误,远调数据为:{}", JSON.toJSONString(listResult));
return null;
}
}
@Bean
public DynamicDataSource dynamicDataSource(DruidDataSourceFactory druidDataSourceFactory) {
// 企业列表 企业CODE端口IP
Map<Object, Object> dataSourceMap = new HashMap<>();
dataSourceInfoList()
.stream()
.map(DataSourceInfo::hostAndPortBuild)
.forEach(dataSourceInfo -> {
dataSourceMap.put(dataSourceInfo.getKey(), druidDataSourceFactory.create(dataSourceInfo));
});
//设置动态数据源
DynamicDataSource dynamicDataSource = new DynamicDataSource();
// dynamicDataSource.setDefaultTargetDataSource(masterDataSource());
dynamicDataSource.setTargetDataSources(dataSourceMap);
//将数据源信息备份在defineTargetDataSources中
dynamicDataSource.setDefineTargetDataSources(dataSourceMap);
log.info("动态数据源加载完成,持有key{}",dynamicDataSource.getKeys());
return dynamicDataSource;
}
@Override
public void run(ApplicationArguments args) {
DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class);
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
for (EntInfo entInfo : dataSourceInfoList()) {
DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(entInfo);
DruidDataSource druidDataSource = druidDataSourceFactory.create(dataSourceInfo);
dynamicDataSource.put(dataSourceInfo.getKey(), druidDataSource);
log.info("存储数据连接池为key:{}",dataSourceInfo.getKey());
}
}
// @Bean
// public SqlSessionFactory sqlSessionFactory(DynamicDataSource dataSource) throws Exception {
// SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
// sessionFactory.setDataSource(dataSource);
// return sessionFactory.getObject();
// }
}

View File

@ -0,0 +1,19 @@
package com.muyu.cloud.common.many.datasource.constents;
/**
* @author DongZl
* @description:
* @Date 2023-8-1 11:02
*/
public class DatasourceContent {
public final static String DATASOURCE_URL = "jdbc:mysql://{}:{}/{}?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8";
public final static String USER_NAME = "root";
public final static String PASSWORD = "bawei2112A";
public final static String IP = "47.116.173.119";
public final static Integer PORT = 3306;
}

View File

@ -0,0 +1,60 @@
package com.muyu.cloud.common.many.datasource.domain.model;
import com.muyu.cloud.common.many.datasource.constents.DatasourceContent;
import com.muyu.cloud.common.saas.domain.model.EntInfo;
import com.muyu.common.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author DongZl
* @description:
* @Date 2023-8-1 11:15
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DataSourceInfo {
/**
*
*/
private String key;
/**
*
*/
private String url;
/**
*
*/
private String userName;
/**
*
*/
private String password;
// public static DataSourceInfo hostAndPortBuild(String key, String host, Integer port) {
// return DataSourceInfo.builder()
// .key(key)
// .url(StringUtils.format(DatasourceContent.DATASOURCE_URL, host, port, key))
// .password(DatasourceContent.PASSWORD)
// .userName(DatasourceContent.USER_NAME)
// .build();
// }
public static DataSourceInfo hostAndPortBuild(EntInfo entInfo) {
return DataSourceInfo.builder()
.key(entInfo.getEntCode())
.url(StringUtils.format(DatasourceContent.DATASOURCE_URL, entInfo.getIp(), entInfo.getPort(), entInfo.getDbName()))
.userName(entInfo.getUserName())
.password(entInfo.getPassword())
.build();
}
}

View File

@ -0,0 +1,40 @@
package com.muyu.cloud.common.many.datasource.factory;
import com.alibaba.druid.pool.DruidDataSource;
import com.muyu.cloud.common.many.datasource.domain.model.DataSourceInfo;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;
import java.sql.SQLException;
/**
* @Author: DongZeLiang
* @date: 2024/6/3
* @Description: Druid
* @Version: 1.0
*/
@Log4j2
@Component
public class DruidDataSourceFactory {
/**
* @Description:
* @Author Dongzl
*/
public DruidDataSource create(DataSourceInfo dataSourceInfo) {
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setUrl(dataSourceInfo.getUrl());
druidDataSource.setUsername(dataSourceInfo.getUserName());
druidDataSource.setPassword(dataSourceInfo.getPassword());
druidDataSource.setBreakAfterAcquireFailure(true);
druidDataSource.setConnectionErrorRetryAttempts(0);
try {
druidDataSource.getConnection(2000);
log.info("{} -> 数据源连接成功", dataSourceInfo.getKey());
return druidDataSource;
} catch (SQLException throwables) {
log.error("数据源 {} 连接失败,用户名:{},密码 {}",dataSourceInfo.getUrl(),dataSourceInfo.getUserName(),dataSourceInfo.getPassword());
return null;
}
}
}

View File

@ -0,0 +1,42 @@
package com.muyu.cloud.common.many.datasource.holder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
/**
*
*
* @author Dongzl
*/
@Slf4j
public class DynamicDataSourceHolder {
/**
*
*/
private static final ThreadLocal<String> DYNAMIC_DATASOURCE_KEY = new ThreadLocal<>();
/**
* /线使
*/
public static void setDynamicDataSourceKey(String key){
log.info("数据源切换为:{}",key);
DYNAMIC_DATASOURCE_KEY.set(key);
}
/**
* 使mater
*/
public static String getDynamicDataSourceKey(){
String key = DYNAMIC_DATASOURCE_KEY.get();
Assert.notNull(key, "请携带数据标识");
return key;
}
/**
*
*/
public static void removeDynamicDataSourceKey(){
log.info("移除数据源:{}",DYNAMIC_DATASOURCE_KEY.get());
DYNAMIC_DATASOURCE_KEY.remove();
}
}

View File

@ -0,0 +1,60 @@
package com.muyu.cloud.common.many.datasource.role;
import com.alibaba.druid.pool.DruidDataSource;
import com.muyu.cloud.common.many.datasource.holder.DynamicDataSourceHolder;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
import java.util.List;
import java.util.Map;
/**
*
* AddDefineDataSourceaddDefineDynamicDataSourcetargetdatasourcesmapmaptargetdatasourcesmap
* 使@DataSource(value = "数据源名称")DynamicDataSourceContextHolder.setContextKey("数据源名称")
* @author Dongzl
*/
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DynamicDataSource extends AbstractRoutingDataSource {
/**
*
*/
private Map<Object, Object> defineTargetDataSources;
/**
*
* @param key
* @return true false
*/
public boolean hashKey(String key){
return defineTargetDataSources.containsKey(key);
}
/**
*
* @param key
* @param value
*/
public void put(String key, DruidDataSource value) {
defineTargetDataSources.put(key, value);
this.afterPropertiesSet();
}
/**
* 线使
*/
@Override
protected Object determineCurrentLookupKey() {
return DynamicDataSourceHolder.getDynamicDataSourceKey();
}
public List<Object> getKeys() {
return defineTargetDataSources.keySet().stream().toList();
}
}

View File

@ -0,0 +1,12 @@
package com.muyu.cloud.common.saas.contents;
/**
* @Author: DongZeLiang
* @date: 2024/6/3
* @Description: SAAS
* @Version: 1.0
*/
public class SaaSConstant {
public final static String SAAS_KEY = "ent-code";
}

View File

@ -0,0 +1,31 @@
package com.muyu.cloud.common.saas.domain.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author: DongZeLiang
* @date: 2024/6/3
* @Description:
* @Version: 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class EntInfo {
private String entCode;
private String ip;
private Integer port;
private String dbName;
private String userName;
private String password;
}

View File

@ -0,0 +1,28 @@
package com.muyu.cloud.common.saas.exception;
import com.muyu.common.core.exception.ServiceException;
/**
* @Author: DongZeLiang
* @date: 2024/6/3
* @Description: SaaS
* @Version: 1.0
*/
public class SaaSException extends ServiceException {
public SaaSException (String message, Integer code) {
super(message, code);
}
public SaaSException (String message) {
super(message);
}
/**
*
*/
public SaaSException () {
super();
}
}

View File

@ -0,0 +1,57 @@
package com.muyu.cloud.common.saas.interceptor;
import com.alibaba.fastjson2.JSONObject;
import com.muyu.cloud.common.saas.contents.SaaSConstant;
import com.muyu.cloud.common.many.datasource.holder.DynamicDataSourceHolder;
import com.muyu.cloud.common.saas.exception.SaaSException;
import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
import com.muyu.common.core.context.SecurityContextHolder;
import com.muyu.common.core.utils.ServletUtils;
import com.muyu.common.core.utils.SpringUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.AsyncHandlerInterceptor;
/**
* @Author: DongZeLiang
* @date: 2024/6/3
* @Description: SAAS
* @Version: 1.0
*/
@Slf4j
public class SaaSInterceptor implements AsyncHandlerInterceptor {
/**
*
*/
@Override
public boolean preHandle (HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
if (!(handler instanceof HandlerMethod)) {
return true;
}
String saasKey = ServletUtils.getHeader(request, SaaSConstant.SAAS_KEY);
log.info("访问路径:{}携带SaaSKey{}",request.getRequestURI(),saasKey);
if (saasKey == null) {
throw new SaaSException("SaaS非法访问");
}else {
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
if (!dynamicDataSource.hashKey(saasKey)){
throw new SaaSException("SaaS非法访问");
}
}
DynamicDataSourceHolder.setDynamicDataSourceKey(saasKey);
return true;
}
/**
*
*/
@Override
public void afterConcurrentHandlingStarted (HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
DynamicDataSourceHolder.removeDynamicDataSourceKey();
}
}

View File

@ -0,0 +1,31 @@
package com.muyu.cloud.common.saas.interceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
*
*
* @author muyu
*/
public class WebMvcSaaSConfig implements WebMvcConfigurer {
/**
*
*/
public static final String[] excludeUrls = {"/login", "/logout", "/refresh"};
@Override
public void addInterceptors (InterceptorRegistry registry) {
registry.addInterceptor(getHeaderInterceptor())
.addPathPatterns("/**")
.excludePathPatterns(excludeUrls)
.order(-10);
}
/**
*
*/
public SaaSInterceptor getHeaderInterceptor () {
return new SaaSInterceptor();
}
}

View File

@ -0,0 +1,3 @@
com.muyu.cloud.common.saas.interceptor.WebMvcSaaSConfig
com.muyu.cloud.common.many.datasource.ManyDataSource
com.muyu.cloud.common.many.datasource.factory.DruidDataSourceFactory

View File

@ -28,6 +28,7 @@ public class HeaderInterceptor implements AsyncHandlerInterceptor {
}
SecurityContextHolder.setUserId(ServletUtils.getHeader(request, SecurityConstants.DETAILS_USER_ID));
SecurityContextHolder.setSaasKey(ServletUtils.getHeader(request, SecurityConstants.SAAS_KEY));
SecurityContextHolder.setUserName(ServletUtils.getHeader(request, SecurityConstants.DETAILS_USERNAME));
SecurityContextHolder.setUserKey(ServletUtils.getHeader(request, SecurityConstants.USER_KEY));

View File

@ -55,10 +55,11 @@ public class TokenService {
claimsMap.put(SecurityConstants.USER_KEY, token);
claimsMap.put(SecurityConstants.DETAILS_USER_ID, userId);
claimsMap.put(SecurityConstants.DETAILS_USERNAME, userName);
claimsMap.put(SecurityConstants.SAAS_KEY,loginUser.getSysUser().getFirmCode());
// 接口返回信息
Map<String, Object> rspMap = new HashMap<String, Object>();
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
rspMap.put("ent_code", loginUser.getSysUser().getFirmCode());
rspMap.put("expires_in", expireTime);
return rspMap;
}

View File

@ -30,6 +30,10 @@ public class SecurityUtils {
return SecurityContextHolder.getUserName();
}
public static String getSaasKey () {
return SecurityContextHolder.getSaasKey();
}
/**
* key
*/

View File

@ -63,4 +63,6 @@ public class LoginUser implements Serializable {
*/
private SysUser sysUser;
}

View File

@ -34,6 +34,8 @@ public class SysDept extends BaseEntity {
*/
private Long parentId;
private String firmCode;
/**
*
*/

View File

@ -0,0 +1,37 @@
package com.muyu.common.system.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author: DongZeLiang
* @date: 2024/6/3
* @Description:
* @Version: 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("sys_ent")
public class SysEnt {
@TableId( type = IdType.AUTO)
private Integer id;
private String entCode;
private String ip;
private Integer port;
private String dbName;
private String userName;
private String password;
}

View File

@ -0,0 +1,25 @@
package com.muyu.common.system.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
* @Author WangXin
* @Data 2024/9/18
* @Description
* @Version 1.0.0
*/
@EqualsAndHashCode(callSuper = true)
@Data
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
public class SysFirmUser extends SysUser {
/**
*
*/
private String databaseName;
}

View File

@ -49,6 +49,9 @@ public class SysUser extends BaseEntity {
@Excel(name = "登录名称")
private String userName;
private String firmCode;
/**
*
*/
@ -135,6 +138,8 @@ public class SysUser extends BaseEntity {
*/
private Long roleId;
public SysUser (Long userId) {
this.userId = userId;
}

View File

@ -0,0 +1,23 @@
package com.muyu.common.system.remote;
import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result;
import com.muyu.common.system.domain.SysEnt;
import com.muyu.common.system.remote.factory.RemoteEntFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
*
*
* @author muyu
*/
@FeignClient(contextId = "remoteEntService", value = ServiceNameConstants.SYSTEM_SERVICE, fallbackFactory = RemoteEntFallbackFactory.class)
public interface RemoteEntService {
}

View File

@ -3,12 +3,17 @@ package com.muyu.common.system.remote;
import com.muyu.common.core.constant.SecurityConstants;
import com.muyu.common.core.constant.ServiceNameConstants;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.system.domain.SysEnt;
import com.muyu.common.system.domain.SysFirmUser;
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.*;
import java.util.List;
/**
*
*
@ -24,8 +29,8 @@ public interface RemoteUserService {
*
* @return
*/
@GetMapping("/user/info/{username}")
public Result<LoginUser> getUserInfo (@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@GetMapping("/user/info")
public Result<LoginUser> getUserInfo (@RequestParam("firmCode") String firmCode,@RequestParam("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
/**
*
@ -37,4 +42,10 @@ public interface RemoteUserService {
*/
@PostMapping("/user/register")
public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
@GetMapping("/user/companyList")
public Result<List<SysUser>> companyList ();
@PostMapping("/ent/list")
public Result<List<SysEnt>> list (@RequestBody SysEnt sysEnt);
}

View File

@ -0,0 +1,34 @@
package com.muyu.common.system.remote.factory;
/**
* @Author:
* @Name: RemoteEntFallbackFactory
* @Description:
* @CreatedDate: 2024/9/20 3:11
* @FilePath: com.muyu.common.system.remote
*/
import com.muyu.common.core.domain.Result;
import com.muyu.common.system.domain.SysEnt;
import com.muyu.common.system.remote.RemoteEntService;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @Author:
* @Name: RemoteEntFallbackFactory
* @Description:
* @CreatedDate: 2024/9/20 3:11
* @FilePath: com.muyu.common.system.remote
*/
@Component
public class RemoteEntFallbackFactory implements FallbackFactory<RemoteEntService> {
@Override
public RemoteEntService create(Throwable cause) {
return new RemoteEntService() {
};
}
}

View File

@ -1,6 +1,9 @@
package com.muyu.common.system.remote.factory;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.system.domain.SysEnt;
import com.muyu.common.system.domain.SysFirmUser;
import com.muyu.common.system.remote.RemoteUserService;
import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.domain.LoginUser;
@ -9,6 +12,8 @@ import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
/**
*
*
@ -22,8 +27,9 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
public RemoteUserService create (Throwable throwable) {
log.error("用户服务调用失败:{}", throwable.getMessage());
return new RemoteUserService() {
@Override
public Result<LoginUser> getUserInfo (String username, String source) {
public Result<LoginUser> getUserInfo(String firmCode, String username, String source) {
return Result.error("获取用户失败:" + throwable.getMessage());
}
@ -31,6 +37,17 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
public Result<Boolean> registerUserInfo (SysUser sysUser, String source) {
return Result.error("注册用户失败:" + throwable.getMessage());
}
@Override
public Result<List<SysUser>> companyList() {
return Result.error("获取企业列表失败:" + throwable.getMessage());
}
@Override
public Result<List<SysEnt>> list(SysEnt sysEnt) {
return Result.error("获取企业列表失败:" + throwable.getMessage());
}
};
}
}

View File

@ -1,3 +1,4 @@
com.muyu.common.system.remote.factory.RemoteUserFallbackFactory
com.muyu.common.system.remote.factory.RemoteLogFallbackFactory
com.muyu.common.system.remote.factory.RemoteFileFallbackFactory
com.muyu.common.system.remote.factory.RemoteEntFallbackFactory

View File

@ -7,9 +7,9 @@ import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
@Log4j2
@Component
//@Component
public class XXLJobConfig {
@Bean
// @Bean
public XxlJobSpringExecutor xxlJobExecutor(XxlJobProperties xxlJobProperties) {
if (StringUtils.isEmpty(xxlJobProperties.getAdminAddresses())){
throw new RuntimeException("请在bootstrap.yml当中配置shared-configs项xxl-job共享配置[application-xxl-config]");

View File

@ -20,6 +20,7 @@
<module>cloud-common-system</module>
<module>cloud-common-xxl</module>
<module>cloud-common-rabbit</module>
<module>cloud-common-saas</module>
</modules>
<artifactId>cloud-common</artifactId>

105
cloud-firm/pom.xml 100644
View File

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.muyu</groupId>
<artifactId>cloud-server</artifactId>
<version>3.6.3</version>
</parent>
<artifactId>cloud-firm</artifactId>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-saas</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- SpringCloud Alibaba Nacos Config -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<!-- SpringCloud Alibaba Sentinel -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<!-- SpringBoot Actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<!-- MuYu Common DataSource -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-datasource</artifactId>
</dependency>
<!-- MuYu Common DataScope -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-datascope</artifactId>
</dependency>
<!-- MuYu Common Log -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-log</artifactId>
</dependency>
<!-- 接口模块 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-api-doc</artifactId>
</dependency>
<!-- XllJob定时任务 -->
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-xxl</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,25 @@
package com.muyu.cloud.firm;
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
import com.muyu.common.security.annotation.EnableCustomConfig;
import com.muyu.common.security.annotation.EnableMyFeignClients;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@EnableCustomConfig
@EnableMyFeignClients
@SpringBootApplication(
exclude = {
DataSourceAutoConfiguration.class,
DruidDataSourceAutoConfigure.class,
DynamicDataSourceAutoConfiguration.class
}
)
public class FirmApplication {
public static void main(String[] args) {
SpringApplication.run(FirmApplication.class, args);
}
}

View File

@ -0,0 +1,107 @@
package com.muyu.cloud.firm.controller;
import com.muyu.cloud.firm.service.ISysFirmService;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.cloud.firm.domain.SysFirm;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
/**
* Controller
*
* @author muyu
* @date 2024-09-18
*/
@RestController
@RequestMapping("/firmInfo")
public class SysFirmController extends BaseController
{
@Resource
private ISysFirmService sysFirmService;
/**
*
*/
@RequiresPermissions("firm:firmInfo:list")
@GetMapping("/list")
public Result<TableDataInfo<SysFirm>> list(SysFirm sysFirm)
{
startPage();
List<SysFirm> list = sysFirmService.selectSysFirmList(sysFirm);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("firm:firmInfo:export")
@PostMapping("/export")
public void export(HttpServletResponse response, SysFirm sysFirm)
{
List<SysFirm> list = sysFirmService.selectSysFirmList(sysFirm);
ExcelUtil<SysFirm> util = new ExcelUtil<SysFirm>(SysFirm.class);
util.exportExcel(response, list, "企业基础信息数据");
}
/**
*
*/
@RequiresPermissions("firm:firmInfo:query")
@GetMapping(value = "/{id}")
public Result<List<SysFirm>> getInfo(@PathVariable("id") Long id)
{
return success(sysFirmService.selectSysFirmById(id));
}
/**
*
*/
@RequiresPermissions("firm:firmInfo:add")
@PostMapping
public Result<Integer> add(
@Validated @RequestBody SysFirm sysFirm)
{
if (sysFirmService.checkIdUnique(sysFirm)) {
return error("新增 企业基础信息 '" + sysFirm + "'失败,企业基础信息已存在");
}
sysFirm.setCreateBy(SecurityUtils.getUsername());
return toAjax(sysFirmService.save(sysFirm));
}
/**
*
*/
@RequiresPermissions("firm:firmInfo:edit")
@PutMapping
public Result<Integer> edit(
@Validated @RequestBody SysFirm sysFirm)
{
if (!sysFirmService.checkIdUnique(sysFirm)) {
return error("修改 企业基础信息 '" + sysFirm + "'失败,企业基础信息不存在");
}
sysFirm.setUpdateBy(SecurityUtils.getUsername());
return toAjax(sysFirmService.updateById(sysFirm));
}
/**
*
*/
@RequiresPermissions("firm:firmInfo:remove")
@DeleteMapping("/{ids}")
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
{
sysFirmService.removeBatchByIds(Arrays.asList(ids));
return success();
}
}

View File

@ -0,0 +1,72 @@
package com.muyu.cloud.firm.domain;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
/**
* sys_firm
*
* @author muyu
* @date 2024-09-18
*/
@Data
@Setter
@Getter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("sys_firm")
public class SysFirm extends BaseEntity{
private static final long serialVersionUID = 1L;
/** 自增主键 */
@TableId( type = IdType.AUTO)
private Long id;
/** 统一社会信用代码 */
@Excel(name = "统一社会信用代码")
private String firmCreditCode;
/** 企业编码 */
@Excel(name = "企业编码")
private String firmCode;
/** 企业名称 */
@Excel(name = "企业名称")
private String firmName;
/** 企业logs */
@Excel(name = "企业logs")
private String firmLogs;
/** 启用状态(1.开业 2.停业 3.休业) */
@Excel(name = "启用状态(1.开业 2.停业 3.休业)")
private String state;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("firmCreditCode", getFirmCreditCode())
.append("firmCode", getFirmCode())
.append("firmName", getFirmName())
.append("firmLogs", getFirmLogs())
.append("state", getState())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}

View File

@ -0,0 +1,19 @@
package com.muyu.cloud.firm.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.cloud.firm.domain.SysFirm;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* Mapper
*
* @author muyu
* @date 2024-09-18
*/
@Mapper
public interface SysFirmMapper extends BaseMapper<SysFirm>{
List<SysFirm> selectSysFirmList(SysFirm sysFirm);
}

View File

@ -0,0 +1,39 @@
package com.muyu.cloud.firm.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.cloud.firm.domain.SysFirm;
import java.util.List;
/**
* Service
*
* @author muyu
* @date 2024-09-18
*/
public interface ISysFirmService extends IService<SysFirm> {
/**
*
*
* @param id
* @return
*/
public SysFirm selectSysFirmById(Long id);
/**
*
*
* @param sysFirm
* @return
*/
public List<SysFirm> selectSysFirmList(SysFirm sysFirm);
/**
* id
*
* @param sysFirm
* @return
*/
Boolean checkIdUnique(SysFirm sysFirm);
}

View File

@ -0,0 +1,70 @@
package com.muyu.cloud.firm.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.cloud.firm.domain.SysFirm;
import com.muyu.cloud.firm.mapper.SysFirmMapper;
import com.muyu.cloud.firm.service.ISysFirmService;
import com.muyu.common.core.utils.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.annotation.Resource;
import java.util.List;
/**
* Service
*
* @author muyu
* @date 2024-09-18
*/
@Service
public class SysFirmServiceImpl
extends ServiceImpl<SysFirmMapper, SysFirm>
implements ISysFirmService {
@Resource
private SysFirmMapper sysFirmMapper;
/**
*
*
* @param id
* @return
*/
@Override
public SysFirm selectSysFirmById(Long id)
{
LambdaQueryWrapper<SysFirm> queryWrapper = new LambdaQueryWrapper<>();
Assert.notNull(id, "id不可为空");
queryWrapper.eq(SysFirm::getId, id);
return this.getOne(queryWrapper);
}
/**
*
*
* @param sysFirm
* @return
*/
@Override
public List<SysFirm> selectSysFirmList(SysFirm sysFirm) {
return sysFirmMapper.selectSysFirmList(sysFirm);
}
/**
*
* @param sysFirm
* @return
*/
@Override
public Boolean checkIdUnique(SysFirm sysFirm) {
LambdaQueryWrapper<SysFirm> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysFirm::getId, sysFirm.getId());
return this.count(queryWrapper) > 0;
}
}

View File

@ -0,0 +1,2 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}

View File

@ -0,0 +1,58 @@
# Tomcat
server:
port: 49701
# nacos线上地址
nacos:
addr: 47.116.173.119:8848
user-name: nacos
password: nacos
namespace: one-saas
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
# Spring
spring:
amqp:
deserialization:
trust:
all: true
main:
allow-bean-definition-overriding: true
application:
# 应用名称
name: cloud-platform-firm
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: ${nacos.addr}
# nacos用户名
username: ${nacos.user-name}
# nacos密码
password: ${nacos.password}
# 命名空间
namespace: ${nacos.namespace}
config:
# 服务注册地址
server-addr: ${nacos.addr}
# nacos用户名
username: ${nacos.user-name}
# nacos密码
password: ${nacos.password}
# 命名空间
namespace: ${nacos.namespace}
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
# 系统共享配置
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
# 系统环境Config共享配置
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
logging:
level:
com.muyu.cloud.mapper: DEBUG

View File

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/cloud-car"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/cloud-car"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.sky.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 使用gRpc将日志发送到skywalking服务端 -->
<appender name="GRPC_LOG" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<Pattern>${log.sky.pattern}</Pattern>
</layout>
</encoder>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="GRPC_LOG"/>
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<!-- 日志存放路径 -->
<property name="log.path" value="logs/cloud-car"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.sky.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 使用gRpc将日志发送到skywalking服务端 -->
<appender name="GRPC_LOG" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
<Pattern>${log.sky.pattern}</Pattern>
</layout>
</encoder>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.muyu" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="GRPC_LOG"/>
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
</configuration>

View File

@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.cloud.firm.mapper.SysFirmMapper">
<resultMap type="com.muyu.cloud.firm.domain.SysFirm" id="SysFirmResult">
<result property="id" column="id" />
<result property="firmCreditCode" column="firm_credit_code" />
<result property="firmCode" column="firm_code" />
<result property="firmName" column="firm_name" />
<result property="firmLogs" column="firm_logs" />
<result property="state" column="state" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectSysFirmVo">
select id, firm_credit_code, firm_code, firm_name, firm_logs , state, create_by, create_time, update_by, update_time, remark from sys_firm
</sql>
<select id="selectSysFirmList" parameterType="com.muyu.cloud.firm.domain.SysFirm" resultMap="SysFirmResult">
<include refid="selectSysFirmVo"/>
<where>
<if test="firmName != null and firmName != ''"> and firm_name like concat('%', #{firmName}, '%')</if>
<if test="state != null and state != ''"> and state = #{state}</if>
</where>
</select>
<select id="selectSysFirmById" parameterType="Long" resultMap="SysFirmResult">
<include refid="selectSysFirmVo"/>
where id = #{id}
</select>
<insert id="insertSysFirm" parameterType="com.muyu.cloud.firm.domain.SysFirm" useGeneratedKeys="true" keyProperty="id">
insert into sys_firm
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="firmCreditCode != null and firmCreditCode != ''">firm_credit_code,</if>
<if test="firmCode != null">firm_code,</if>
<if test="firmName != null">firm_name,</if>
<if test="firmLogs != null">firm_logs,</if>
<if test="state != null">state,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="firmCreditCode != null and firmCreditCode != ''">#{firmCreditCode},</if>
<if test="firmCode != null">#{firmCode},</if>
<if test="firmName != null">#{firmName},</if>
<if test="firmLogs != null">#{firmLogs},</if>
<if test="state != null">#{state},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateSysFirm" parameterType="com.muyu.cloud.firm.domain.SysFirm">
update sys_firm
<trim prefix="SET" suffixOverrides=",">
<if test="firmCreditCode != null and firmCreditCode != ''">firm_credit_code = #{firmCreditCode},</if>
<if test="firmCode != null">firm_code = #{firmCode},</if>
<if test="firmName != null">firm_name = #{firmName},</if>
<if test="firmLogs != null">firm_logs = #{firmLogs},</if>
<if test="state != null">state = #{state},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteSysFirmById" parameterType="Long">
delete from sys_firm where id = #{id}
</delete>
<delete id="deleteSysFirmByIds" parameterType="String">
delete from sys_firm where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -81,7 +81,6 @@
<artifactId>knife4j-gateway-spring-boot-starter</artifactId>
<version>4.5.0</version>
</dependency>
</dependencies>
<build>

View File

@ -63,6 +63,7 @@ public class AuthFilter implements GlobalFilter, Ordered {
}
String userid = JwtUtils.getUserId(claims);
String username = JwtUtils.getUserName(claims);
String saasKey = JwtUtils.getSaasKey(claims);
if (StringUtils.isEmpty(userid) || StringUtils.isEmpty(username)) {
return unauthorizedResponse(exchange, "令牌验证失败");
}
@ -71,6 +72,7 @@ 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);
addHeader(mutate,SecurityConstants.SAAS_KEY,saasKey);
// 内部请求来源参数清除
removeHeader(mutate, SecurityConstants.FROM_SOURCE);
return chain.filter(exchange.mutate().request(mutate.build()).build());

View File

@ -4,8 +4,6 @@ import cn.hutool.core.net.NetUtil;
import cn.hutool.core.util.ArrayUtil;
import com.alibaba.fastjson2.JSONObject;
import lombok.extern.log4j.Log4j2;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.gateway.route.Route;
import org.springframework.cloud.gateway.support.ServerWebExchangeUtils;
import org.springframework.core.io.buffer.DataBufferFactory;
@ -18,8 +16,6 @@ import reactor.core.publisher.Mono;
/**
* Web
*
*
*/
@Log4j2
public class WebFrameworkUtils {
@ -72,8 +68,6 @@ public class WebFrameworkUtils {
/**
* IP
*
*
* @param exchange
* @param otherHeaderNames header
* @return IP
@ -91,7 +85,6 @@ public class WebFrameworkUtils {
return NetUtil.getMultistageReverseProxyIp(ip);
}
}
// 方式二,通过 remoteAddress 获取
if (exchange.getRequest().getRemoteAddress() == null) {
return null;
@ -102,7 +95,6 @@ public class WebFrameworkUtils {
/**
* Route
*
* @param exchange
* @return
*/

View File

@ -4,10 +4,10 @@ server:
# nacos线上地址
nacos:
addr: 106.54.193.225:8848
addr: 47.116.173.119:8848
user-name: nacos
password: nacos
namespace: one
namespace: one-saas
# Spring
spring:

View File

@ -1,13 +1,13 @@
# Tomcat
server:
port: 9300
port: 9301
# nacos线上地址
nacos:
addr: 106.54.193.225:8848
addr: 47.116.173.119:8848
user-name: nacos
password: nacos
namespace: one
namespace: one-saas
# Spring
spring:

View File

@ -16,5 +16,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
public class CloudGenApplication {
public static void main (String[] args) {
SpringApplication.run(CloudGenApplication.class, args);
System.out.println("CloudGen 模块启动成功!");
}
}

View File

@ -1,22 +1,24 @@
package com.muyu.gen.controller;
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.domain.Result;
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;
import com.muyu.gen.domain.GenTableResp;
import com.muyu.gen.service.IGenTableColumnService;
import com.muyu.gen.service.IGenTableService;
import jakarta.servlet.http.HttpServletResponse;
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;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
@ -25,15 +27,19 @@ import java.util.Map;
/**
*
*
* @author muyu
* @author ruoyi
*/
@RequestMapping("/gen")
@RestController
public class GenController extends BaseController {
@Autowired
public class GenController extends BaseController
{
@Resource
private IGenTableService genTableService;
@Autowired
@Resource
private HttpServletResponse response;
@Resource
private IGenTableColumnService genTableColumnService;
/**
@ -41,7 +47,8 @@ public class GenController extends BaseController {
*/
@RequiresPermissions("tool:gen:list")
@GetMapping("/list")
public Result<TableDataInfo<GenTable>> genList (GenTable genTable) {
public Result genList(GenTable genTable)
{
startPage();
List<GenTable> list = genTableService.selectGenTableList(genTable);
return getDataTable(list);
@ -52,7 +59,8 @@ public class GenController extends BaseController {
*/
@RequiresPermissions("tool:gen:query")
@GetMapping(value = "/{tableId}")
public Result getInfo (@PathVariable("tableId") Long tableId) {
public Result getInfo(@PathVariable("tableId") Long tableId)
{
GenTable table = genTableService.selectGenTableById(tableId);
List<GenTable> tables = genTableService.selectGenTableAll();
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
@ -63,12 +71,14 @@ public class GenController extends BaseController {
return success(map);
}
/**
*
*/
@RequiresPermissions("tool:gen:list")
@GetMapping("/db/list")
public Result<TableDataInfo<GenTable>> dataList (GenTable genTable) {
public Result dataList(GenTable genTable)
{
startPage();
List<GenTable> list = genTableService.selectDbTableList(genTable);
return getDataTable(list);
@ -78,26 +88,26 @@ public class GenController extends BaseController {
*
*/
@GetMapping(value = "/column/{tableId}")
public Result<TableDataInfo<GenTableColumn>> columnList (Long tableId) {
public Result columnList(@PathVariable("tableId") Long tableId)
{
TableDataInfo dataInfo = new TableDataInfo();
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
return Result.success(
TableDataInfo.<GenTableColumn>builder()
.total(list.size())
.rows(list)
.build()
);
dataInfo.setRows(list);
dataInfo.setTotal(list.size());
return success(dataInfo);
}
/**
*
*/
@RequiresPermissions("tool:gen:import")
// @RequiresPermissions("tool:gen:import")
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
@PostMapping("/importTable")
public Result importTableSave (String tables) {
public Result importTableSave(@RequestParam("tables") String tables, @RequestParam("dbName") String dbName)
{
String[] tableNames = Convert.toStrArray(tables);
// 查询表信息
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames,dbName);
genTableService.importGenTable(tableList);
return success();
}
@ -108,7 +118,8 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:edit")
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
@PutMapping
public Result editSave (@Validated @RequestBody GenTable genTable) {
public Result editSave(@Validated @RequestBody GenTable genTable)
{
genTableService.validateEdit(genTable);
genTableService.updateGenTable(genTable);
return success();
@ -120,7 +131,8 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:remove")
@Log(title = "代码生成", businessType = BusinessType.DELETE)
@DeleteMapping("/{tableIds}")
public Result remove (@PathVariable("tableIds") Long[] tableIds) {
public Result remove(@PathVariable("tableIds") Long[] tableIds)
{
genTableService.deleteGenTableByIds(tableIds);
return success();
}
@ -130,7 +142,8 @@ public class GenController extends BaseController {
*/
@RequiresPermissions("tool:gen:preview")
@GetMapping("/preview/{tableId}")
public Result preview (@PathVariable("tableId") Long tableId) throws IOException {
public Result preview(@PathVariable("tableId") Long tableId) throws IOException
{
Map<String, String> dataMap = genTableService.previewCode(tableId);
return success(dataMap);
}
@ -141,7 +154,8 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:code")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/download/{tableName}")
public void download (HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
public void download(@PathVariable("tableName") String tableName) throws IOException
{
byte[] data = genTableService.downloadCode(tableName);
genCode(response, data);
}
@ -152,7 +166,8 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:code")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/genCode/{tableName}")
public Result genCode (@PathVariable("tableName") String tableName) {
public Result genCode(@PathVariable("tableName") String tableName)
{
genTableService.generatorCode(tableName);
return success();
}
@ -162,9 +177,10 @@ public class GenController extends BaseController {
*/
@RequiresPermissions("tool:gen:edit")
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
@GetMapping("/synchDb/{tableName}")
public Result synchDb (@PathVariable("tableName") String tableName) {
genTableService.synchDb(tableName);
@GetMapping("/synchDb/{tableName}/{dbName}")
public Result synchDb(@PathVariable("tableName") String tableName,@PathVariable("dbName") String dbName)
{
genTableService.synchDb(tableName,dbName);
return success();
}
@ -174,7 +190,8 @@ public class GenController extends BaseController {
@RequiresPermissions("tool:gen:code")
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
@GetMapping("/batchGenCode")
public void batchGenCode (HttpServletResponse response, String tables) throws IOException {
public void batchGenCode(@RequestParam("tables") String tables) throws IOException
{
String[] tableNames = Convert.toStrArray(tables);
byte[] data = genTableService.downloadCode(tableNames);
genCode(response, data);
@ -183,11 +200,37 @@ public class GenController extends BaseController {
/**
* zip
*/
private void genCode (HttpServletResponse response, byte[] data) throws IOException {
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.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\"");
response.addHeader("Content-Length", "" + data.length);
response.setContentType("application/octet-stream; charset=UTF-8");
IOUtils.write(data, response.getOutputStream());
}
/**
*
*/
@GetMapping("/db/selDbNameAll")
public Result<List<String>> selDbNameAll(){
return Result.success(genTableService.selDbNameAll());
}
/**
* ,
*/
@GetMapping("/db/listAll")
public Result<List<GenTableResp>> genListAll() {
return success(genTableService.selectDbTableListAll());
}
/**
*
*/
@GetMapping("/selectDbTableColumnsByName")
public Result<List<GenTableColumn>> selTableAll(@RequestParam("dbName") String dbName,@RequestParam("table") String table){
List<GenTableColumn> genTableColumns = genTableColumnService.selectDbTableColumnsByName(table, dbName);
return Result.success(genTableColumns);
}
}

View File

@ -35,6 +35,8 @@ public class GenTable extends BaseEntity {
*/
private Long tableId;
private String dbName;
/**
*
*/

View File

@ -0,0 +1,43 @@
package com.muyu.gen.domain;
import com.muyu.common.core.constant.GenConstants;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.core.web.domain.BaseEntity;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.ArrayUtils;
import java.util.List;
/**
* gen_table
*
* @author muyu
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class GenTableResp extends BaseEntity {
private String dbName;
/**
*
*/
private String tableName;
/**
*
*/
private String tableComment;
}

View File

@ -1,67 +1,64 @@
package com.muyu.gen.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.gen.domain.GenTableColumn;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
*
* @author muyu
* @author ruoyi
*/
public interface GenTableColumnMapper extends BaseMapper<GenTableColumn> {
public interface GenTableColumnMapper
{
/**
*
*
* @param tableName
*
* @param dbName
* @return
*/
List<GenTableColumn> selectDbTableColumnsByName (String tableName);
public List<GenTableColumn> selectDbTableColumnsByName(@Param("tableName") String tableName, @Param("dbName") String dbName);
/**
*
*
* @param tableId
*
* @return
*/
List<GenTableColumn> selectGenTableColumnListByTableId (Long tableId);
public List<GenTableColumn> selectGenTableColumnListByTableId(@Param("tableId") Long tableId);
/**
*
*
* @param genTableColumn
*
* @return
*/
int insertGenTableColumn (GenTableColumn genTableColumn);
public int insertGenTableColumn(GenTableColumn genTableColumn);
/**
*
*
* @param genTableColumn
*
* @return
*/
int updateGenTableColumn (GenTableColumn genTableColumn);
public int updateGenTableColumn(GenTableColumn genTableColumn);
/**
*
*
* @param genTableColumns
*
* @return
*/
int deleteGenTableColumns (List<GenTableColumn> genTableColumns);
public int deleteGenTableColumns(@Param("genTableColumns") List<GenTableColumn> genTableColumns);
/**
*
*
* @param ids ID
*
* @return
*/
int deleteGenTableColumnByIds (Long[] ids);
public int deleteGenTableColumnByIds(@Param("ids") Long[] ids);
}

View File

@ -1,92 +1,91 @@
package com.muyu.gen.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.gen.domain.GenTable;
import com.muyu.gen.domain.GenTableResp;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
*
* @author muyu
* @author ruoyi
*/
public interface GenTableMapper extends BaseMapper<GenTable> {
public interface GenTableMapper
{
/**
*
*
* @param genTable
*
* @return
*/
List<GenTable> selectGenTableList (GenTable genTable);
public List<GenTable> selectGenTableList(GenTable genTable);
/**
*
*
* @param genTable
*
* @return
*/
List<GenTable> selectDbTableList (GenTable genTable);
public List<GenTable> selectDbTableList(GenTable genTable);
/**
*
*
* @param tableNames
*
* @param dbName
* @return
*/
List<GenTable> selectDbTableListByNames (String[] tableNames);
public List<GenTable> selectDbTableListByNames(@Param("tableNames") String[] tableNames, @Param("dbName") String dbName);
/**
*
*
* @return
*/
List<GenTable> selectGenTableAll ();
public List<GenTable> selectGenTableAll();
/**
* ID
*
* @param id ID
*
* @return
*/
GenTable selectGenTableById (Long id);
public GenTable selectGenTableById(@Param("id") Long id);
/**
*
*
* @param tableName
*
* @return
*/
GenTable selectGenTableByName (String tableName);
public GenTable selectGenTableByName(@Param("tableName") String tableName);
/**
*
*
* @param genTable
*
* @return
*/
int insertGenTable (GenTable genTable);
public int insertGenTable(GenTable genTable);
/**
*
*
* @param genTable
*
* @return
*/
int updateGenTable (GenTable genTable);
public int updateGenTable(GenTable genTable);
/**
*
*
* @param ids ID
*
* @return
*/
int deleteGenTableByIds (Long[] ids);
public int deleteGenTableByIds(@Param("ids") Long[] ids);
List<String> selDbNameAll();
List<GenTableResp> selectDbTableListAll();
}

View File

@ -3,7 +3,7 @@ package com.muyu.gen.service;
import com.muyu.common.core.text.Convert;
import com.muyu.gen.domain.GenTableColumn;
import com.muyu.gen.mapper.GenTableColumnMapper;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;
@ -11,58 +11,64 @@ import java.util.List;
/**
*
*
* @author muyu
* @author ruoyi
*/
@Service
public class GenTableColumnServiceImpl implements IGenTableColumnService {
@Autowired
private GenTableColumnMapper genTableColumnMapper;
public class GenTableColumnServiceImpl implements IGenTableColumnService
{
@Resource
private GenTableColumnMapper genTableColumnMapper;
/**
/**
*
*
* @param tableId
*
* @return
*/
@Override
public List<GenTableColumn> selectGenTableColumnListByTableId (Long tableId) {
return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
}
@Override
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId)
{
return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
}
/**
*
*
* @param genTableColumn
*
* @return
*/
@Override
public int insertGenTableColumn (GenTableColumn genTableColumn) {
return genTableColumnMapper.insertGenTableColumn(genTableColumn);
}
@Override
public int insertGenTableColumn(GenTableColumn genTableColumn)
{
return genTableColumnMapper.insertGenTableColumn(genTableColumn);
}
/**
/**
*
*
* @param genTableColumn
*
* @return
*/
@Override
public int updateGenTableColumn (GenTableColumn genTableColumn) {
return genTableColumnMapper.updateGenTableColumn(genTableColumn);
}
@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));
}
@Override
public int deleteGenTableColumnByIds (String ids) {
return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
public List<GenTableColumn> selectDbTableColumnsByName(String table, String dbName) {
return genTableColumnMapper.selectDbTableColumnsByName(table,dbName);
}
}

View File

@ -10,6 +10,7 @@ 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;
import com.muyu.gen.domain.GenTableResp;
import com.muyu.gen.mapper.GenTableColumnMapper;
import com.muyu.gen.mapper.GenTableMapper;
import com.muyu.gen.util.GenUtils;
@ -22,7 +23,7 @@ import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -41,43 +42,28 @@ import java.util.zip.ZipOutputStream;
/**
*
*
* @author muyu
* @author ruoyi
*/
@Service
public class GenTableServiceImpl implements IGenTableService {
public class GenTableServiceImpl implements IGenTableService
{
private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
@Autowired
@Resource
private GenTableMapper genTableMapper;
@Autowired
@Resource
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) {
public GenTable selectGenTableById(Long id)
{
GenTable genTable = genTableMapper.selectGenTableById(id);
setTableFromOptions(genTable);
return genTable;
@ -87,11 +73,11 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param genTable
*
* @return
*/
@Override
public List<GenTable> selectGenTableList (GenTable genTable) {
public List<GenTable> selectGenTableList(GenTable genTable)
{
return genTableMapper.selectGenTableList(genTable);
}
@ -99,11 +85,11 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param genTable
*
* @return
*/
@Override
public List<GenTable> selectDbTableList (GenTable genTable) {
public List<GenTable> selectDbTableList(GenTable genTable)
{
return genTableMapper.selectDbTableList(genTable);
}
@ -111,12 +97,13 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param tableNames
*
* @param dbName
* @return
*/
@Override
public List<GenTable> selectDbTableListByNames (String[] tableNames) {
return genTableMapper.selectDbTableListByNames(tableNames);
public List<GenTable> selectDbTableListByNames(String[] tableNames, String dbName)
{
return genTableMapper.selectDbTableListByNames(tableNames,dbName);
}
/**
@ -125,7 +112,8 @@ public class GenTableServiceImpl implements IGenTableService {
* @return
*/
@Override
public List<GenTable> selectGenTableAll () {
public List<GenTable> selectGenTableAll()
{
return genTableMapper.selectGenTableAll();
}
@ -133,17 +121,19 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param genTable
*
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void updateGenTable (GenTable genTable) {
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()) {
if (row > 0)
{
for (GenTableColumn cenTableColumn : genTable.getColumns())
{
genTableColumnMapper.updateGenTableColumn(cenTableColumn);
}
}
@ -153,12 +143,12 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param tableIds ID
*
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteGenTableByIds (Long[] tableIds) {
public void deleteGenTableByIds(Long[] tableIds)
{
genTableMapper.deleteGenTableByIds(tableIds);
genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
}
@ -170,23 +160,31 @@ public class GenTableServiceImpl implements IGenTableService {
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void importGenTable (List<GenTable> tableList) {
public void importGenTable(List<GenTable> tableList)
{
String operName = SecurityUtils.getUsername();
try {
for (GenTable table : tableList) {
try
{
for (GenTable table : tableList)
{
String dbName = table.getDbName();
String tableName = table.getTableName();
GenUtils.initTable(table, operName);
int row = genTableMapper.insertGenTable(table);
if (row > 0) {
if (row > 0)
{
// 保存列信息
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
for (GenTableColumn column : genTableColumns) {
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName, dbName);
for (GenTableColumn column : genTableColumns)
{
GenUtils.initColumnField(column, table);
genTableColumnMapper.insertGenTableColumn(column);
}
}
}
} catch (Exception e) {
}
catch (Exception e)
{
throw new ServiceException("导入失败:" + e.getMessage());
}
}
@ -195,11 +193,11 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param tableId
*
* @return
*/
@Override
public Map<String, String> previewCode (Long tableId) {
public Map<String, String> previewCode(Long tableId)
{
Map<String, String> dataMap = new LinkedHashMap<>();
// 查询表信息
GenTable table = genTableMapper.selectGenTableById(tableId);
@ -213,7 +211,8 @@ public class GenTableServiceImpl implements IGenTableService {
// 获取模板列表
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
for (String template : templates) {
for (String template : templates)
{
// 渲染模板
StringWriter sw = new StringWriter();
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
@ -227,11 +226,11 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param tableName
*
* @return
*/
@Override
public byte[] downloadCode (String tableName) {
public byte[] downloadCode(String tableName)
{
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream);
generatorCode(tableName, zip);
@ -245,7 +244,8 @@ public class GenTableServiceImpl implements IGenTableService {
* @param tableName
*/
@Override
public void generatorCode (String tableName) {
public void generatorCode(String tableName)
{
// 查询表信息
GenTable table = genTableMapper.selectGenTableByName(tableName);
// 设置主子表信息
@ -259,16 +259,21 @@ public class GenTableServiceImpl implements IGenTableService {
// 获取模板列表
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
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"))
{
// 渲染模板
StringWriter sw = new StringWriter();
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
tpl.merge(context, sw);
try {
try
{
String path = getGenPath(table, template);
FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8);
} catch (IOException e) {
}
catch (IOException e)
{
throw new ServiceException("渲染模板失败,表名:" + table.getTableName());
}
}
@ -279,45 +284,54 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param tableName
* @param dbName
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void synchDb (String tableName) {
public void synchDb(String tableName, String dbName)
{
GenTable table = genTableMapper.selectGenTableByName(tableName);
List<GenTableColumn> tableColumns = table.getColumns();
Map<String, GenTableColumn> tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity()));
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
if (StringUtils.isEmpty(dbTableColumns)) {
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName, dbName);
if (StringUtils.isEmpty(dbTableColumns))
{
throw new ServiceException("同步数据失败,原表结构不存在");
}
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
dbTableColumns.forEach(column -> {
GenUtils.initColumnField(column, table);
if (tableColumnMap.containsKey(column.getColumnName())) {
if (tableColumnMap.containsKey(column.getColumnName()))
{
GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName());
column.setColumnId(prevColumn.getColumnId());
if (column.isList()) {
if (column.isList())
{
// 如果是列表,继续保留查询方式/字典类型选项
column.setDictType(prevColumn.getDictType());
column.setQueryType(prevColumn.getQueryType());
}
if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk()
&& (column.isInsert() || column.isEdit())
&& ((column.isUsableColumn()) || (!column.isSuperColumn()))) {
&& ((column.isUsableColumn()) || (!column.isSuperColumn())))
{
// 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项
column.setIsRequired(prevColumn.getIsRequired());
column.setHtmlType(prevColumn.getHtmlType());
}
genTableColumnMapper.updateGenTableColumn(column);
} else {
}
else
{
genTableColumnMapper.insertGenTableColumn(column);
}
});
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
if (StringUtils.isNotEmpty(delColumns)) {
if (StringUtils.isNotEmpty(delColumns))
{
genTableColumnMapper.deleteGenTableColumns(delColumns);
}
}
@ -326,14 +340,15 @@ public class GenTableServiceImpl implements IGenTableService {
*
*
* @param tableNames
*
* @return
*/
@Override
public byte[] downloadCode (String[] tableNames) {
public byte[] downloadCode(String[] tableNames)
{
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(outputStream);
for (String tableName : tableNames) {
for (String tableName : tableNames)
{
generatorCode(tableName, zip);
}
IOUtils.closeQuietly(zip);
@ -343,7 +358,8 @@ public class GenTableServiceImpl implements IGenTableService {
/**
*
*/
private void generatorCode (String tableName, ZipOutputStream zip) {
private void generatorCode(String tableName, ZipOutputStream zip)
{
// 查询表信息
GenTable table = genTableMapper.selectGenTableByName(tableName);
// 设置主子表信息
@ -357,19 +373,23 @@ public class GenTableServiceImpl implements IGenTableService {
// 获取模板列表
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
for (String template : templates) {
for (String template : templates)
{
// 渲染模板
StringWriter sw = new StringWriter();
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
tpl.merge(context, sw);
try {
try
{
// 添加到zip
zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
IOUtils.write(sw.toString(), zip, Constants.UTF8);
IOUtils.closeQuietly(sw);
zip.flush();
zip.closeEntry();
} catch (IOException e) {
}
catch (IOException e)
{
log.error("渲染模板失败,表名:" + table.getTableName(), e);
}
}
@ -381,49 +401,80 @@ public class GenTableServiceImpl implements IGenTableService {
* @param genTable
*/
@Override
public void validateEdit (GenTable genTable) {
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
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))) {
if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE)))
{
throw new ServiceException("树编码字段不能为空");
} else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) {
}
else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE)))
{
throw new ServiceException("树父编码字段不能为空");
} else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) {
}
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())) {
}
else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory()))
{
if (StringUtils.isEmpty(genTable.getSubTableName()))
{
throw new ServiceException("关联子表的表名不能为空");
} else if (StringUtils.isEmpty(genTable.getSubTableFkName())) {
}
else if (StringUtils.isEmpty(genTable.getSubTableFkName()))
{
throw new ServiceException("子表关联的外键名不能为空");
}
}
}
}
@Override
public List<String> selDbNameAll() {
return genTableMapper.selDbNameAll();
}
@Override
public List<GenTableResp> selectDbTableListAll() {
return genTableMapper.selectDbTableListAll();
}
/**
*
*
* @param table
*/
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())
{
table.setPkColumn(column);
break;
}
}
if (StringUtils.isNull(table.getPkColumn())) {
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()) {
if (GenConstants.TPL_SUB.equals(table.getTplCategory()))
{
for (GenTableColumn column : table.getSubTable().getColumns())
{
if (column.isPk())
{
table.getSubTable().setPkColumn(column);
break;
}
}
if (StringUtils.isNull(table.getSubTable().getPkColumn())) {
if (StringUtils.isNull(table.getSubTable().getPkColumn()))
{
table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
}
}
@ -434,9 +485,11 @@ public class GenTableServiceImpl implements IGenTableService {
*
* @param table
*/
public void setSubTable (GenTable table) {
public void setSubTable(GenTable table)
{
String subTableName = table.getSubTableName();
if (StringUtils.isNotEmpty(subTableName)) {
if (StringUtils.isNotEmpty(subTableName))
{
table.setSubTable(genTableMapper.selectGenTableByName(subTableName));
}
}
@ -446,9 +499,11 @@ public class GenTableServiceImpl implements IGenTableService {
*
* @param genTable
*/
public void setTableFromOptions (GenTable genTable) {
public void setTableFromOptions(GenTable genTable)
{
JSONObject paramsObj = JSON.parseObject(genTable.getOptions());
if (StringUtils.isNotNull(paramsObj)) {
if (StringUtils.isNotNull(paramsObj))
{
String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
@ -462,4 +517,21 @@ public class GenTableServiceImpl implements IGenTableService {
genTable.setParentMenuName(parentMenuName);
}
}
/**
*
*
* @param table
* @param template
* @return
*/
public static String getGenPath(GenTable table, String template)
{
String genPath = table.getGenPath();
if (StringUtils.equals(genPath, "/"))
{
return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table);
}
return genPath + File.separator + VelocityUtils.getFileName(template, table);
}
}

View File

@ -7,42 +7,41 @@ import java.util.List;
/**
*
*
* @author muyu
* @author ruoyi
*/
public interface IGenTableColumnService {
public interface IGenTableColumnService
{
/**
*
*
* @param tableId
*
* @return
*/
List<GenTableColumn> selectGenTableColumnListByTableId (Long tableId);
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
/**
*
*
* @param genTableColumn
*
* @return
*/
int insertGenTableColumn (GenTableColumn genTableColumn);
public int insertGenTableColumn(GenTableColumn genTableColumn);
/**
*
*
* @param genTableColumn
*
* @return
*/
int updateGenTableColumn (GenTableColumn genTableColumn);
public int updateGenTableColumn(GenTableColumn genTableColumn);
/**
*
*
* @param ids ID
*
* @return
*/
int deleteGenTableColumnByIds (String ids);
public int deleteGenTableColumnByIds(String ids);
List<GenTableColumn> selectDbTableColumnsByName(String table, String dbName);
}

View File

@ -1,6 +1,7 @@
package com.muyu.gen.service;
import com.muyu.gen.domain.GenTable;
import com.muyu.gen.domain.GenTableResp;
import java.util.List;
import java.util.Map;
@ -8,124 +9,121 @@ import java.util.Map;
/**
*
*
* @author muyu
* @author ruoyi
*/
public interface IGenTableService {
public interface IGenTableService
{
/**
*
*
* @param genTable
*
* @return
*/
List<GenTable> selectGenTableList (GenTable genTable);
public List<GenTable> selectGenTableList(GenTable genTable);
/**
*
*
* @param genTable
*
* @return
*/
List<GenTable> selectDbTableList (GenTable genTable);
public List<GenTable> selectDbTableList(GenTable genTable);
/**
*
*
* @param tableNames
*
* @param dbName
* @return
*/
List<GenTable> selectDbTableListByNames (String[] tableNames);
public List<GenTable> selectDbTableListByNames(String[] tableNames, String dbName);
/**
*
*
* @return
*/
List<GenTable> selectGenTableAll ();
public List<GenTable> selectGenTableAll();
/**
*
*
* @param id ID
*
* @return
*/
GenTable selectGenTableById (Long id);
public GenTable selectGenTableById(Long id);
/**
*
*
* @param genTable
*
* @return
*/
void updateGenTable (GenTable genTable);
public void updateGenTable(GenTable genTable);
/**
*
*
* @param tableIds ID
*
* @return
*/
void deleteGenTableByIds (Long[] tableIds);
public void deleteGenTableByIds(Long[] tableIds);
/**
*
*
* @param tableList
*/
void importGenTable (List<GenTable> tableList);
public void importGenTable(List<GenTable> tableList);
/**
*
*
* @param tableId
*
* @return
*/
Map<String, String> previewCode (Long tableId);
public Map<String, String> previewCode(Long tableId);
/**
*
*
* @param tableName
*
* @return
*/
byte[] downloadCode (String tableName);
public byte[] downloadCode(String tableName);
/**
*
*
* @param tableName
*
* @return
*/
void generatorCode (String tableName);
public void generatorCode(String tableName);
/**
*
*
* @param tableName
* @param dbName
*/
void synchDb (String tableName);
public void synchDb(String tableName, String dbName);
/**
*
*
* @param tableNames
*
* @return
*/
byte[] downloadCode (String[] tableNames);
public byte[] downloadCode(String[] tableNames);
/**
*
*
* @param genTable
*/
void validateEdit (GenTable genTable);
public void validateEdit(GenTable genTable);
List<String> selDbNameAll();
List<GenTableResp> selectDbTableListAll();
}

View File

@ -1,16 +1,20 @@
# Tomcat
server:
port: 9202
port: 9709
# nacos线上地址
nacos:
addr: 106.54.193.225:8848
addr: 47.116.173.119:8848
user-name: nacos
password: nacos
namespace: one
namespace: one-saas
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
# Spring
spring:
amqp:
deserialization:
trust:
all: true
main:
allow-bean-definition-overriding: true
application:
@ -49,3 +53,8 @@ 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}
# rabbit 配置文件
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
logging:
level:
com.muyu.system.mapper: DEBUG

View File

@ -1,58 +1,36 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.gen.mapper.GenTableColumnMapper">
<resultMap type="com.muyu.gen.domain.GenTableColumn" id="GenTableColumnResult">
<id property="columnId" column="column_id"/>
<result property="tableId" column="table_id"/>
<result property="columnName" column="column_name"/>
<result property="columnComment" column="column_comment"/>
<result property="columnType" column="column_type"/>
<result property="javaType" column="java_type"/>
<result property="javaField" column="java_field"/>
<result property="isPk" column="is_pk"/>
<result property="isIncrement" column="is_increment"/>
<result property="isRequired" column="is_required"/>
<result property="isInsert" column="is_insert"/>
<result property="isEdit" column="is_edit"/>
<result property="isList" column="is_list"/>
<result property="isQuery" column="is_query"/>
<result property="queryType" column="query_type"/>
<result property="htmlType" column="html_type"/>
<result property="dictType" column="dict_type"/>
<result property="sort" column="sort"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<id property="columnId" column="column_id" />
<result property="tableId" column="table_id" />
<result property="columnName" column="column_name" />
<result property="columnComment" column="column_comment" />
<result property="columnType" column="column_type" />
<result property="javaType" column="java_type" />
<result property="javaField" column="java_field" />
<result property="isPk" column="is_pk" />
<result property="isIncrement" column="is_increment" />
<result property="isRequired" column="is_required" />
<result property="isInsert" column="is_insert" />
<result property="isEdit" column="is_edit" />
<result property="isList" column="is_list" />
<result property="isQuery" column="is_query" />
<result property="queryType" column="query_type" />
<result property="htmlType" column="html_type" />
<result property="dictType" column="dict_type" />
<result property="sort" column="sort" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectGenTableColumnVo">
select column_id,
table_id,
column_name,
column_comment,
column_type,
java_type,
java_field,
is_pk,
is_increment,
is_required,
is_insert,
is_edit,
is_list,
is_query,
query_type,
html_type,
dict_type,
sort,
create_by,
create_time,
update_by,
update_time
from gen_table_column
<sql id="selectGenTableColumnVo">
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
</sql>
<select id="selectGenTableColumnListByTableId" parameterType="com.muyu.gen.domain.GenTableColumn" resultMap="GenTableColumnResult">
@ -62,61 +40,55 @@
</select>
<select id="selectDbTableColumnsByName" parameterType="String" resultMap="GenTableColumnResult">
select column_name,
(case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required,
(case when column_key = 'PRI' then '1' else '0' end) as is_pk,
ordinal_position as sort,
column_comment,
(case when extra = 'auto_increment' then '1' else '0' end) as is_increment,
column_type
from information_schema.columns
where table_schema = (select database())
and table_name = (#{tableName})
order by ordinal_position
</select>
select column_name, (case when (is_nullable = 'no' <![CDATA[ && ]]> column_key != 'PRI') then '1' else null end) as is_required, (case when column_key = 'PRI' then '1' else '0' end) as is_pk, ordinal_position as sort, column_comment, (case when extra = 'auto_increment' then '1' else '0' end) as is_increment, column_type
from information_schema.columns where
<include refid="com.muyu.gen.mapper.GenTableMapper.select_dbName"/>
and table_name = (#{tableName})
order by ordinal_position
</select>
<insert id="insertGenTableColumn" parameterType="com.muyu.gen.domain.GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
insert into gen_table_column (
<if test="tableId != null and tableId != ''">table_id,</if>
<if test="columnName != null and columnName != ''">column_name,</if>
<if test="columnComment != null and columnComment != ''">column_comment,</if>
<if test="columnType != null and columnType != ''">column_type,</if>
<if test="javaType != null and javaType != ''">java_type,</if>
<if test="javaField != null and javaField != ''">java_field,</if>
<if test="isPk != null and isPk != ''">is_pk,</if>
<if test="isIncrement != null and isIncrement != ''">is_increment,</if>
<if test="isRequired != null and isRequired != ''">is_required,</if>
<if test="isInsert != null and isInsert != ''">is_insert,</if>
<if test="isEdit != null and isEdit != ''">is_edit,</if>
<if test="isList != null and isList != ''">is_list,</if>
<if test="isQuery != null and isQuery != ''">is_query,</if>
<if test="queryType != null and queryType != ''">query_type,</if>
<if test="htmlType != null and htmlType != ''">html_type,</if>
<if test="dictType != null and dictType != ''">dict_type,</if>
<if test="sort != null">sort,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="tableId != null and tableId != ''">#{tableId},</if>
<if test="columnName != null and columnName != ''">#{columnName},</if>
<if test="columnComment != null and columnComment != ''">#{columnComment},</if>
<if test="columnType != null and columnType != ''">#{columnType},</if>
<if test="javaType != null and javaType != ''">#{javaType},</if>
<if test="javaField != null and javaField != ''">#{javaField},</if>
<if test="isPk != null and isPk != ''">#{isPk},</if>
<if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
<if test="isRequired != null and isRequired != ''">#{isRequired},</if>
<if test="isInsert != null and isInsert != ''">#{isInsert},</if>
<if test="isEdit != null and isEdit != ''">#{isEdit},</if>
<if test="isList != null and isList != ''">#{isList},</if>
<if test="isQuery != null and isQuery != ''">#{isQuery},</if>
<if test="queryType != null and queryType != ''">#{queryType},</if>
<if test="htmlType != null and htmlType != ''">#{htmlType},</if>
<if test="dictType != null and dictType != ''">#{dictType},</if>
<if test="sort != null">#{sort},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
<if test="tableId != null and tableId != ''">table_id,</if>
<if test="columnName != null and columnName != ''">column_name,</if>
<if test="columnComment != null and columnComment != ''">column_comment,</if>
<if test="columnType != null and columnType != ''">column_type,</if>
<if test="javaType != null and javaType != ''">java_type,</if>
<if test="javaField != null and javaField != ''">java_field,</if>
<if test="isPk != null and isPk != ''">is_pk,</if>
<if test="isIncrement != null and isIncrement != ''">is_increment,</if>
<if test="isRequired != null and isRequired != ''">is_required,</if>
<if test="isInsert != null and isInsert != ''">is_insert,</if>
<if test="isEdit != null and isEdit != ''">is_edit,</if>
<if test="isList != null and isList != ''">is_list,</if>
<if test="isQuery != null and isQuery != ''">is_query,</if>
<if test="queryType != null and queryType != ''">query_type,</if>
<if test="htmlType != null and htmlType != ''">html_type,</if>
<if test="dictType != null and dictType != ''">dict_type,</if>
<if test="sort != null">sort,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="tableId != null and tableId != ''">#{tableId},</if>
<if test="columnName != null and columnName != ''">#{columnName},</if>
<if test="columnComment != null and columnComment != ''">#{columnComment},</if>
<if test="columnType != null and columnType != ''">#{columnType},</if>
<if test="javaType != null and javaType != ''">#{javaType},</if>
<if test="javaField != null and javaField != ''">#{javaField},</if>
<if test="isPk != null and isPk != ''">#{isPk},</if>
<if test="isIncrement != null and isIncrement != ''">#{isIncrement},</if>
<if test="isRequired != null and isRequired != ''">#{isRequired},</if>
<if test="isInsert != null and isInsert != ''">#{isInsert},</if>
<if test="isEdit != null and isEdit != ''">#{isEdit},</if>
<if test="isList != null and isList != ''">#{isList},</if>
<if test="isQuery != null and isQuery != ''">#{isQuery},</if>
<if test="queryType != null and queryType != ''">#{queryType},</if>
<if test="htmlType != null and htmlType != ''">#{htmlType},</if>
<if test="dictType != null and dictType != ''">#{dictType},</if>
<if test="sort != null">#{sort},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<update id="updateGenTableColumn" parameterType="com.muyu.gen.domain.GenTableColumn">
@ -141,17 +113,20 @@
</update>
<delete id="deleteGenTableColumnByIds" parameterType="Long">
delete from gen_table_column where table_id in
<foreach collection="array" item="tableId" open="(" separator="," close=")">
delete from gen_table_column where table_id in (
<foreach collection="ids" item="tableId" separator="," >
#{tableId}
</foreach>
)
</delete>
<delete id="deleteGenTableColumns">
delete from gen_table_column where column_id in
<foreach collection="list" item="item" open="(" separator="," close=")">
delete from gen_table_column where column_id in (
<foreach collection="genTableColumns" item="item" separator="," >
#{item.columnId}
</foreach>
)
</delete>
</mapper>

View File

@ -1,291 +1,208 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.gen.mapper.GenTableMapper">
<resultMap type="com.muyu.gen.domain.GenTable" id="GenTableResult">
<id property="tableId" column="table_id"/>
<result property="tableName" column="table_name"/>
<result property="tableComment" column="table_comment"/>
<result property="subTableName" column="sub_table_name"/>
<result property="subTableFkName" column="sub_table_fk_name"/>
<result property="className" column="class_name"/>
<result property="tplCategory" column="tpl_category"/>
<result property="packageName" column="package_name"/>
<result property="moduleName" column="module_name"/>
<result property="businessName" column="business_name"/>
<result property="functionName" column="function_name"/>
<result property="functionAuthor" column="function_author"/>
<result property="genType" column="gen_type"/>
<result property="genPath" column="gen_path"/>
<result property="options" column="options"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="remark" column="remark"/>
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult"/>
<resultMap type="com.muyu.gen.domain.GenTable" id="GenTableResult">
<id property="tableId" column="table_id" />
<result property="dbName" column="db_name" />
<result property="tableName" column="table_name" />
<result property="tableComment" column="table_comment" />
<result property="subTableName" column="sub_table_name" />
<result property="subTableFkName" column="sub_table_fk_name" />
<result property="className" column="class_name" />
<result property="tplCategory" column="tpl_category" />
<result property="packageName" column="package_name" />
<result property="moduleName" column="module_name" />
<result property="businessName" column="business_name" />
<result property="functionName" column="function_name" />
<result property="functionAuthor" column="function_author" />
<result property="genType" column="gen_type" />
<result property="genPath" column="gen_path" />
<result property="options" column="options" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
</resultMap>
<resultMap type="com.muyu.gen.domain.GenTableColumn" id="GenTableColumnResult">
<id property="columnId" column="column_id" />
<result property="tableId" column="table_id" />
<result property="columnName" column="column_name" />
<result property="columnComment" column="column_comment" />
<result property="columnType" column="column_type" />
<result property="javaType" column="java_type" />
<result property="javaField" column="java_field" />
<result property="isPk" column="is_pk" />
<result property="isIncrement" column="is_increment" />
<result property="isRequired" column="is_required" />
<result property="isInsert" column="is_insert" />
<result property="isEdit" column="is_edit" />
<result property="isList" column="is_list" />
<result property="isQuery" column="is_query" />
<result property="queryType" column="query_type" />
<result property="htmlType" column="html_type" />
<result property="dictType" column="dict_type" />
<result property="sort" column="sort" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<resultMap type="com.muyu.gen.domain.GenTableColumn" id="GenTableColumnResult">
<id property="columnId" column="column_id"/>
<result property="tableId" column="table_id"/>
<result property="columnName" column="column_name"/>
<result property="columnComment" column="column_comment"/>
<result property="columnType" column="column_type"/>
<result property="javaType" column="java_type"/>
<result property="javaField" column="java_field"/>
<result property="isPk" column="is_pk"/>
<result property="isIncrement" column="is_increment"/>
<result property="isRequired" column="is_required"/>
<result property="isInsert" column="is_insert"/>
<result property="isEdit" column="is_edit"/>
<result property="isList" column="is_list"/>
<result property="isQuery" column="is_query"/>
<result property="queryType" column="query_type"/>
<result property="htmlType" column="html_type"/>
<result property="dictType" column="dict_type"/>
<result property="sort" column="sort"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectGenTableVo">
select table_id,
table_name,
table_comment,
sub_table_name,
sub_table_fk_name,
class_name,
tpl_category,
package_name,
module_name,
business_name,
function_name,
function_author,
gen_type,
gen_path,
options,
create_by,
create_time,
update_by,
update_time,
remark
from gen_table
<sql id="selectGenTableVo">
select table_id, db_name, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
</sql>
<sql id="select_dbName">
<choose>
<when test="dbName!=null and dbName!=''">
table_schema in (#{dbName})
</when>
<otherwise>
table_schema = (select database())
</otherwise>
</choose>
</sql>
<select id="selectGenTableList" parameterType="com.muyu.gen.domain.GenTable" resultMap="GenTableResult">
<include refid="selectGenTableVo"/>
<where>
<if test="tableName != null and tableName != ''">
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
</if>
<if test="tableComment != null and tableComment != ''">
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
</select>
<include refid="selectGenTableVo"/>
<where>
<if test="tableName != null and tableName != ''">
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
</if>
<if test="tableComment != null and tableComment != ''">
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
</where>
</select>
<select id="selectDbTableList" parameterType="com.muyu.gen.domain.GenTable" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
where table_schema = (select database())
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
AND table_name NOT IN (select table_name from gen_table)
<if test="tableName != null and tableName != ''">
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
</if>
<if test="tableComment != null and tableComment != ''">
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
<select id="selectDbTableList" parameterType="com.muyu.gen.domain.GenTable" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
where
<include refid="select_dbName"/>
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
AND table_name NOT IN (select table_name from gen_table)
<if test="tableName != null and tableName != ''">
AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
</if>
<if test="tableComment != null and tableComment != ''">
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
order by create_time desc
</select>
</select>
<select id="selectDbTableListByNames" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
and table_name in
<foreach collection="array" item="name" open="(" separator="," close=")">
#{name}
<select id="selectDbTableListByNames" resultMap="GenTableResult">
select table_name, table_schema db_name, table_comment, create_time, update_time from information_schema.tables
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%'
and <include refid="select_dbName"/>
and table_name in
<foreach collection="tableNames" item="name" open="(" separator="," close=")">
#{name}
</foreach>
</select>
</select>
<select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time
from information_schema.tables
where table_comment <![CDATA[ <> ]]> ''
and table_schema = (select database())
and table_name = #{tableName}
</select>
<select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
select table_name, table_comment, create_time, update_time from information_schema.tables
where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
and table_name = #{tableName}
</select>
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
SELECT t.table_id,
t.table_name,
t.table_comment,
t.sub_table_name,
t.sub_table_fk_name,
t.class_name,
t.tpl_category,
t.package_name,
t.module_name,
t.business_name,
t.function_name,
t.function_author,
t.gen_type,
t.gen_path,
t.options,
t.remark,
c.column_id,
c.column_name,
c.column_comment,
c.column_type,
c.java_type,
c.java_field,
c.is_pk,
c.is_increment,
c.is_required,
c.is_insert,
c.is_edit,
c.is_list,
c.is_query,
c.query_type,
c.html_type,
c.dict_type,
c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_id = #{tableId}
order by c.sort
</select>
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_id = #{id} order by c.sort
</select>
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id,
t.table_name,
t.table_comment,
t.sub_table_name,
t.sub_table_fk_name,
t.class_name,
t.tpl_category,
t.package_name,
t.module_name,
t.business_name,
t.function_name,
t.function_author,
t.gen_type,
t.gen_path,
t.options,
t.remark,
c.column_id,
c.column_name,
c.column_comment,
c.column_type,
c.java_type,
c.java_field,
c.is_pk,
c.is_increment,
c.is_required,
c.is_insert,
c.is_edit,
c.is_list,
c.is_query,
c.query_type,
c.html_type,
c.dict_type,
c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_name = #{tableName}
order by c.sort
</select>
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
where t.table_name = #{tableName} order by c.sort
</select>
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id,
t.table_name,
t.table_comment,
t.sub_table_name,
t.sub_table_fk_name,
t.class_name,
t.tpl_category,
t.package_name,
t.module_name,
t.business_name,
t.function_name,
t.function_author,
t.options,
t.remark,
c.column_id,
c.column_name,
c.column_comment,
c.column_type,
c.java_type,
c.java_field,
c.is_pk,
c.is_increment,
c.is_required,
c.is_insert,
c.is_edit,
c.is_list,
c.is_query,
c.query_type,
c.html_type,
c.dict_type,
c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
order by c.sort
</select>
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
FROM gen_table t
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
order by c.sort
</select>
<select id="selDbNameAll" resultType="java.lang.String">
select table_schema from information_schema.tables
WHERE table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys')
GROUP BY table_schema
</select>
<select id="selFilterableByDbNameAndTableName" resultType="java.lang.String">
<insert id="insertGenTable" parameterType="com.muyu.gen.domain.GenTable" useGeneratedKeys="true" keyProperty="tableId">
</select>
<select id="selectDbTableListAll" resultType="com.muyu.gen.domain.GenTableResp">
select table_name,table_comment,table_schema db_name from information_schema.tables
where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%'
and table_schema in (select table_schema from information_schema.tables
WHERE table_schema NOT IN ('information_schema', 'mysql', 'performance_schema', 'sys')
GROUP BY table_schema)
</select>
<insert id="insertGenTable" parameterType="com.muyu.gen.domain.GenTable" useGeneratedKeys="true" keyProperty="tableId">
insert into gen_table (
<if test="tableName != null">table_name,</if>
<if test="tableComment != null and tableComment != ''">table_comment,</if>
<if test="className != null and className != ''">class_name,</if>
<if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
<if test="packageName != null and packageName != ''">package_name,</if>
<if test="moduleName != null and moduleName != ''">module_name,</if>
<if test="businessName != null and businessName != ''">business_name,</if>
<if test="functionName != null and functionName != ''">function_name,</if>
<if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
<if test="genType != null and genType != ''">gen_type,</if>
<if test="genPath != null and genPath != ''">gen_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="tableName != null">#{tableName},</if>
<if test="tableComment != null and tableComment != ''">#{tableComment},</if>
<if test="className != null and className != ''">#{className},</if>
<if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
<if test="packageName != null and packageName != ''">#{packageName},</if>
<if test="moduleName != null and moduleName != ''">#{moduleName},</if>
<if test="businessName != null and businessName != ''">#{businessName},</if>
<if test="functionName != null and functionName != ''">#{functionName},</if>
<if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
<if test="genType != null and genType != ''">#{genType},</if>
<if test="genPath != null and genPath != ''">#{genPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
<if test="dbName != null">db_name,</if>
<if test="tableName != null">table_name,</if>
<if test="tableComment != null and tableComment != ''">table_comment,</if>
<if test="className != null and className != ''">class_name,</if>
<if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
<if test="packageName != null and packageName != ''">package_name,</if>
<if test="moduleName != null and moduleName != ''">module_name,</if>
<if test="businessName != null and businessName != ''">business_name,</if>
<if test="functionName != null and functionName != ''">function_name,</if>
<if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
<if test="genType != null and genType != ''">gen_type,</if>
<if test="genPath != null and genPath != ''">gen_path,</if>
<if test="remark != null and remark != ''">remark,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="dbName != null">#{dbName},</if>
<if test="tableName != null">#{tableName},</if>
<if test="tableComment != null and tableComment != ''">#{tableComment},</if>
<if test="className != null and className != ''">#{className},</if>
<if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
<if test="packageName != null and packageName != ''">#{packageName},</if>
<if test="moduleName != null and moduleName != ''">#{moduleName},</if>
<if test="businessName != null and businessName != ''">#{businessName},</if>
<if test="functionName != null and functionName != ''">#{functionName},</if>
<if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
<if test="genType != null and genType != ''">#{genType},</if>
<if test="genPath != null and genPath != ''">#{genPath},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<update id="updateGenTable" parameterType="com.muyu.gen.domain.GenTable">
update gen_table
<set>
<if test="dbName != null">db_name = #{dbName},</if>
<if test="tableName != null">table_name = #{tableName},</if>
<if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
<if test="subTableName != null">sub_table_name = #{subTableName},</if>
@ -294,8 +211,7 @@
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
<if test="genType != null and genType != ''">gen_type = #{genType},</if>
<if test="genPath != null and genPath != ''">gen_path = #{genPath},</if>
<if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if>
<if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
<if test="tplCategory != null and tplCategory != ''">tpl_category = #{tplCategory},</if> <if test="packageName != null and packageName != ''">package_name = #{packageName},</if>
<if test="moduleName != null and moduleName != ''">module_name = #{moduleName},</if>
<if test="businessName != null and businessName != ''">business_name = #{businessName},</if>
<if test="functionName != null and functionName != ''">function_name = #{functionName},</if>
@ -308,10 +224,11 @@
</update>
<delete id="deleteGenTableByIds" parameterType="Long">
delete from gen_table where table_id in
<foreach collection="array" item="tableId" open="(" separator="," close=")">
delete from gen_table where table_id in (
<foreach collection="ids" item="tableId" separator="," >
#{tableId}
</foreach>
)
</delete>
</mapper>

View File

@ -1,9 +1,9 @@
package ${packageName}.controller;
import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
@ -12,14 +12,14 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import ${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;
import com.muyu.common.security.utils.SecurityUtils;
import org.springframework.validation.annotation.Validated;
#if($table.crud || $table.sub)
import com.muyu.common.core.web.page.TableDataInfo;
#elseif($table.tree)
@ -35,7 +35,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
@RequestMapping("/${businessName}")
public class ${ClassName}Controller extends BaseController
{
@Autowired
@Resource
private I${ClassName}Service ${className}Service;
/**
@ -44,14 +44,14 @@ public class ${ClassName}Controller extends BaseController
@RequiresPermissions("${permissionPrefix}:list")
@GetMapping("/list")
#if($table.crud || $table.sub)
public Result<TableDataInfo> list(${ClassName} ${className})
public Result<TableDataInfo<${ClassName}>> list(${ClassName} ${className})
{
startPage();
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return getDataTable(list);
}
#elseif($table.tree)
public Result list(${ClassName} ${className})
public Result<${ClassName}> list(${ClassName} ${className})
{
List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
return success(list);
@ -62,7 +62,6 @@ public class ${ClassName}Controller extends BaseController
* 导出${functionName}列表
*/
@RequiresPermissions("${permissionPrefix}:export")
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ${ClassName} ${className})
{
@ -76,7 +75,7 @@ public class ${ClassName}Controller extends BaseController
*/
@RequiresPermissions("${permissionPrefix}:query")
@GetMapping(value = "/{${pkColumn.javaField}}")
public Result getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
public Result<List<${ClassName}>> getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
{
return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
}
@ -85,32 +84,40 @@ public class ${ClassName}Controller extends BaseController
* 新增${functionName}
*/
@RequiresPermissions("${permissionPrefix}:add")
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody ${ClassName} ${className})
public Result<Integer> add(
@Validated @RequestBody ${ClassName} ${className})
{
return toAjax(${className}Service.insert${ClassName}(${className}));
if (${className}Service.checkIdUnique(${className})) {
return error("新增 ${functionName} '" + ${className} + "'失败,${functionName}已存在");
}
${className}.setCreateBy(SecurityUtils.getUsername());
return toAjax(${className}Service.save(${className}));
}
/**
* 修改${functionName}
*/
@RequiresPermissions("${permissionPrefix}:edit")
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody ${ClassName} ${className})
public Result<Integer> edit(
@Validated @RequestBody ${ClassName} ${className})
{
return toAjax(${className}Service.update${ClassName}(${className}));
if (!${className}Service.checkIdUnique(${className})) {
return error("修改 ${functionName} '" + ${className} + "'失败,${functionName}不存在");
}
${className}.setUpdateBy(SecurityUtils.getUsername());
return toAjax(${className}Service.updateById(${className}));
}
/**
* 删除${functionName}
*/
@RequiresPermissions("${permissionPrefix}:remove")
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
@DeleteMapping("/{${pkColumn.javaField}s}")
public Result remove(@PathVariable("${pkColumn.javaField}s") ${pkColumn.javaType}[] ${pkColumn.javaField}s)
public Result<Integer> remove(@PathVariable("${pkColumn.javaField}s") ${pkColumn.javaType}[] ${pkColumn.javaField}s)
{
return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
${className}Service.removeBatchByIds(Arrays.asList(${pkColumn.javaField}s));
return success();
}
}

View File

@ -9,6 +9,13 @@ import com.muyu.common.core.web.domain.BaseEntity;
#elseif($table.tree)
import com.muyu.common.core.web.domain.TreeEntity;
#end
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
/**
* ${functionName}对象 ${tableName}
@ -16,13 +23,20 @@ import com.muyu.common.core.web.domain.TreeEntity;
* @author ${author}
* @date ${datetime}
*/
#if($table.crud || $table.sub)
#set($Entity="BaseEntity")
#elseif($table.tree)
#set($Entity="TreeEntity")
#end
public class ${ClassName} extends ${Entity}
{
@Data
@Setter
@Getter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("${tableName}")
public class ${ClassName} extends ${Entity}{
private static final long serialVersionUID = 1L;
#foreach ($column in $columns)
@ -44,33 +58,19 @@ public class ${ClassName} extends ${Entity}
@Excel(name = "${comment}")
#end
#end
#if($column.javaField == $pkColumn.javaField)
@TableId( type = IdType.AUTO)
#end
private $column.javaType $column.javaField;
#end
#end
#if($table.sub)
/** $table.subTable.functionName信息 */
private List<${subClassName}> ${subclassName}List;
#end
#foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField))
#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
#set($AttrName=$column.javaField)
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
public void set${AttrName}($column.javaType $column.javaField)
{
this.$column.javaField = $column.javaField;
}
public $column.javaType get${AttrName}()
{
return $column.javaField;
}
#end
#end
#if($table.sub)
public List<${subClassName}> get${subClassName}List()

View File

@ -5,6 +5,8 @@ import ${packageName}.domain.${ClassName};
#if($table.sub)
import ${packageName}.domain.${subClassName};
#end
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* ${functionName}Mapper接口
@ -12,80 +14,7 @@ import ${packageName}.domain.${subClassName};
* @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});
@Mapper
public interface ${ClassName}Mapper extends BaseMapper<${ClassName}>{
/**
* 查询${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
}

View File

@ -2,6 +2,7 @@ package ${packageName}.service;
import java.util.List;
import ${packageName}.domain.${ClassName};
import com.baomidou.mybatisplus.extension.service.IService;
/**
* ${functionName}Service接口
@ -9,10 +10,9 @@ import ${packageName}.domain.${ClassName};
* @author ${author}
* @date ${datetime}
*/
public interface I${ClassName}Service
{
public interface I${ClassName}Service extends IService<${ClassName}> {
/**
* 查询${functionName}
* 精确查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
@ -28,34 +28,10 @@ public interface I${ClassName}Service
public List<${ClassName}> select${ClassName}List(${ClassName} ${className});
/**
* 新增${functionName}
*
* 判断 ${functionName} id是否唯一
* @param ${className} ${functionName}
* @return 结果
*/
public int insert${ClassName}(${ClassName} ${className});
Boolean checkIdUnique(${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});
}

View File

@ -7,7 +7,6 @@ import com.muyu.common.core.utils.DateUtils;
#break
#end
#end
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
#if($table.sub)
import java.util.ArrayList;
@ -18,6 +17,10 @@ import ${packageName}.domain.${subClassName};
import ${packageName}.mapper.${ClassName}Mapper;
import ${packageName}.domain.${ClassName};
import ${packageName}.service.I${ClassName}Service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.StringUtils;
import org.springframework.util.Assert;
/**
* ${functionName}Service业务层处理
@ -26,13 +29,12 @@ import ${packageName}.service.I${ClassName}Service;
* @date ${datetime}
*/
@Service
public class ${ClassName}ServiceImpl implements I${ClassName}Service
{
@Autowired
private ${ClassName}Mapper ${className}Mapper;
public class ${ClassName}ServiceImpl
extends ServiceImpl<${ClassName}Mapper, ${ClassName}>
implements I${ClassName}Service {
/**
* 查询${functionName}
* 精确查询${functionName}
*
* @param ${pkColumn.javaField} ${functionName}主键
* @return ${functionName}
@ -40,9 +42,13 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
@Override
public ${ClassName} select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaType} ${pkColumn.javaField})
{
return ${className}Mapper.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField});
LambdaQueryWrapper<${ClassName}> queryWrapper = new LambdaQueryWrapper<>();
Assert.notNull(${pkColumn.javaField}, "${pkColumn.javaField}不可为空");
queryWrapper.eq(${ClassName}::get${pkColumn.capJavaField}, ${pkColumn.javaField});
return this.getOne(queryWrapper);
}
/**
* 查询${functionName}列表
*
@ -52,118 +58,58 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service
@Override
public List<${ClassName}> select${ClassName}List(${ClassName} ${className})
{
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);
}
LambdaQueryWrapper<${ClassName}> queryWrapper = new LambdaQueryWrapper<>();
#foreach($column in $columns)
#set($queryType=$column.queryType)
#set($javaField=$column.javaField)
#set($javaType=$column.javaType)
#set($columnName=$column.columnName)
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#if($column.query)
#if($column.queryType == "EQ")
if (StringUtils.isNotEmpty(${className}.get${AttrName}())){
queryWrapper.eq(${ClassName}::get${AttrName}, ${className}.get${AttrName}());
}
}
#elseif($queryType == "NE")
if (StringUtils.isNotEmpty(${className}.get${AttrName}())){
queryWrapper.ne(${ClassName}::get${AttrName}, ${className}.get${AttrName}());
}
#elseif($queryType == "GT")
if (StringUtils.isNotEmpty(${className}.get${AttrName}())){
queryWrapper.gt(${ClassName}::get${AttrName}, ${className}.get${AttrName}());
}
#elseif($queryType == "GTE")
if (StringUtils.isNotEmpty(${className}.get${AttrName}())){
queryWrapper.ge(${ClassName}::get${AttrName}, ${className}.get${AttrName}());
}
#elseif($queryType == "LT")
if (StringUtils.isNotEmpty(${className}.get${AttrName}())){
queryWrapper.lt(${ClassName}::get${AttrName}, ${className}.get${AttrName}());
}
#elseif($queryType == "LTE")
if (StringUtils.isNotEmpty(${className}.get${AttrName}())){
queryWrapper.le(${ClassName}::get${AttrName}, ${className}.get${AttrName}());
}
#elseif($queryType == "LIKE")
if (StringUtils.isNotEmpty(${className}.get${AttrName}())){
queryWrapper.like(${ClassName}::get${AttrName}, ${className}.get${AttrName}());
}
#end
#end
#end
return this.list(queryWrapper);
}
/**
* 唯一 判断
* @param ${className} ${functionName}
* @return ${functionName}
*/
@Override
public Boolean checkIdUnique(${ClassName} ${className}) {
LambdaQueryWrapper<${ClassName}> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(${ClassName}::get${pkColumn.capJavaField}, ${className}.get${pkColumn.capJavaField}());
return this.count(queryWrapper) > 0;
}
}

View File

@ -17,8 +17,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class ${subClassName} extends BaseEntity
{
public class ${subClassName} extends BaseEntity {
private static final long serialVersionUID = 1L;
#foreach ($column in $subTable.columns)

View File

@ -353,7 +353,7 @@
</template>
<script>
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "@/api/${moduleName}/${businessName}";
import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from "/src/api/${moduleName}/${businessName}";
export default {
name: "${BusinessName}",
@ -448,8 +448,8 @@ export default {
#end
#end
list${BusinessName}(this.queryParams).then(response => {
this.${businessName}List = response.rows;
this.total = response.total;
this.${businessName}List = response.data.rows;
this.total = response.data.total;
this.loading = false;
});
},

View File

@ -77,10 +77,6 @@
<artifactId>cloud-common-xxl</artifactId>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-rabbit</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -1,9 +1,11 @@
package com.muyu.system;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
import com.muyu.common.security.annotation.EnableCustomConfig;
import com.muyu.common.security.annotation.EnableMyFeignClients;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
/**
*

View File

@ -35,6 +35,7 @@ public class SysDeptController extends BaseController {
@RequiresPermissions("system:dept:list")
@GetMapping("/list")
public Result list (SysDept dept) {
dept.setFirmCode(SecurityUtils.getSaasKey());
List<SysDept> depts = deptService.selectDeptList(dept);
return success(depts);
}

View File

@ -0,0 +1,39 @@
package com.muyu.system.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.system.domain.SysEnt;
import com.muyu.system.service.SysEntService;
import javax.annotation.Resource;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
/**
* @Author:
* @Name: SysEnt
* @Description:
* @CreatedDate: 2024/9/20 3:02
* @FilePath: com.muyu.system.controller
*/
@Slf4j
@RestController
@RequestMapping("/ent")
public class SysEntController extends BaseController {
@Resource
private SysEntService service;
/**
*
*/
@PostMapping("/list")
@Operation(summary = "查询集合", description = "查询saas租户数据源表")
public Result<List<SysEnt>> list (@RequestBody SysEnt sysEnt) {
return success(service.getList(sysEnt));
}
}

View File

@ -1,6 +1,7 @@
package com.muyu.system.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.ServletUtils;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.core.utils.file.FileTypeUtils;
import com.muyu.common.core.utils.file.MimeTypeUtils;
@ -15,10 +16,12 @@ import com.muyu.common.system.domain.SysUser;
import com.muyu.common.system.domain.LoginUser;
import com.muyu.system.domain.resp.ProfileResp;
import com.muyu.system.service.SysUserService;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.util.Arrays;
/**
@ -35,16 +38,18 @@ public class SysProfileController extends BaseController {
@Autowired
private TokenService tokenService;
@Autowired
@Resource
private RemoteFileService remoteFileService;
/**
*
*/
@GetMapping
public Result profile () {
String firmCode = SecurityUtils.getSaasKey();
String username = SecurityUtils.getUsername();
SysUser user = userService.selectUserByUserName(username);
SysUser user = userService.selectUserByUserName(firmCode, username);
return Result.success(
ProfileResp.builder()
.roleGroup( userService.selectUserRoleGroup(username) )
@ -86,8 +91,9 @@ public class SysProfileController extends BaseController {
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public Result updatePwd (String oldPassword, String newPassword) {
String firmCode = SecurityUtils.getSaasKey();
String username = SecurityUtils.getUsername();
SysUser user = userService.selectUserByUserName(username);
SysUser user = userService.selectUserByUserName(firmCode, username);
String password = user.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password)) {
return error("修改密码失败,旧密码错误");

View File

@ -67,6 +67,12 @@ public class SysUserController extends BaseController {
return getDataTable(list);
}
@GetMapping("/companyList")
public Result<List<SysUser>> companyList () {
List<SysUser> list = userService.selectCompanyList();
return Result.success(list);
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("system:user:export")
@PostMapping("/export")
@ -97,9 +103,9 @@ public class SysUserController extends BaseController {
*
*/
@InnerAuth
@GetMapping("/info/{username}")
public Result<LoginUser> info (@PathVariable("username") String username) {
SysUser sysUser = userService.selectUserByUserName(username);
@GetMapping("/info")
public Result<LoginUser> info (@RequestParam("firmCode") String firmCode,@RequestParam("username") String username) {
SysUser sysUser = userService.selectUserByUserName(firmCode,username);
if (StringUtils.isNull(sysUser)) {
return Result.error("用户名或密码错误");
}
@ -276,7 +282,7 @@ public class SysUserController extends BaseController {
@RequiresPermissions("system:user:edit")
@Log(title = "用户管理", businessType = BusinessType.GRANT)
@PutMapping("/authRole")
public Result insertAuthRole (Long userId, Long[] roleIds) {
public Result insertAuthRole (@RequestParam("userId") Long userId, @RequestParam("roleIds") Long[] roleIds) {
userService.checkUserDataScope(userId);
userService.insertUserAuth(userId, roleIds);
return success();

View File

@ -0,0 +1,21 @@
package com.muyu.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.common.system.domain.SysEnt;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* @Author:
* @Name: SysEnt
* @Description:
* @CreatedDate: 2024/9/20 3:02
* @FilePath: com.muyu.system.mapper
*/
@Repository
@Mapper
public interface SysEntMapper extends BaseMapper<SysEnt> {
}

View File

@ -46,7 +46,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
*
* @return
*/
public SysUser selectUserByUserName (String userName);
public SysUser selectUserByUserName (@Param("firmCode") String firmCode, @Param("userName") String userName);
/**
* ID
@ -139,4 +139,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
* @return
*/
public SysUser checkEmailUnique (String email);
List<SysUser> selectCompanyList();
}

View File

@ -1,53 +1,53 @@
package com.muyu.system.rabbit;
import com.alibaba.fastjson2.JSONObject;
import com.muyu.system.domain.SysConfig;
import jakarta.annotation.PostConstruct;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Log4j2
@RestController
@RequestMapping("/rabbit/test")
public class RabbitTest {
@Autowired
private RabbitTemplate rabbitTemplate;
@Bean
public Queue initQueue(){
return new Queue("rabbit.test.init");
}
@RabbitListener(queues = "rabbit.test.init")
public void msg(SysConfig sysConfig){
log.info("消息队列:[{}], 消息内容:[{}]", "rabbit.test.init", JSONObject.toJSONString(sysConfig));
}
@PostConstruct
public void init(){
new Thread(() -> {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
SysConfig sysConfig = SysConfig.builder()
.configId(1L)
.configKey("ceshi-key")
.configName("测试名称")
.configType("测试类型")
.configValue("测试值")
.build();
rabbitTemplate.convertAndSend("rabbit.test.init",sysConfig);
}).start();
}
}
//package com.muyu.system.rabbit;
//
//import com.alibaba.fastjson2.JSONObject;
//import com.muyu.system.domain.SysConfig;
//import jakarta.annotation.PostConstruct;
//import lombok.extern.log4j.Log4j2;
//import org.springframework.amqp.core.Queue;
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//@Log4j2
//@RestController
//@RequestMapping("/rabbit/test")
//public class RabbitTest {
//
// @Autowired
// private RabbitTemplate rabbitTemplate;
//
// @Bean
// public Queue initQueue(){
// return new Queue("rabbit.test.init");
// }
//
// @RabbitListener(queues = "rabbit.test.init")
// public void msg(SysConfig sysConfig){
// log.info("消息队列:[{}], 消息内容:[{}]", "rabbit.test.init", JSONObject.toJSONString(sysConfig));
// }
//
// @PostConstruct
// public void init(){
// new Thread(() -> {
// try {
// Thread.sleep(5000);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// SysConfig sysConfig = SysConfig.builder()
// .configId(1L)
// .configKey("ceshi-key")
// .configName("测试名称")
// .configType("测试类型")
// .configValue("测试值")
// .build();
// rabbitTemplate.convertAndSend("rabbit.test.init",sysConfig);
// }).start();
// }
//
//}

View File

@ -0,0 +1,18 @@
package com.muyu.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.common.system.domain.SysEnt;
import java.util.List;
/**
* @Author:
* @Name: SysEnt
* @Description:
* @CreatedDate: 2024/9/20 3:02
* @FilePath: com.muyu.system.service
*/
public interface SysEntService extends IService<SysEnt> {
List<SysEnt> getList(SysEnt sysEnt);
}

View File

@ -45,7 +45,7 @@ public interface SysUserService extends IService<SysUser> {
*
* @return
*/
public SysUser selectUserByUserName (String userName);
public SysUser selectUserByUserName (String firmCode, String userName);
/**
* ID
@ -225,4 +225,7 @@ public interface SysUserService extends IService<SysUser> {
* @return
*/
public String importUser (List<SysUser> userList, Boolean isUpdateSupport, String operName);
List<SysUser> selectCompanyList();
}

View File

@ -0,0 +1,35 @@
package com.muyu.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.system.domain.SysEnt;
import com.muyu.system.mapper.SysEntMapper;
import com.muyu.system.service.SysEntService;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
/**
* @Author:
* @Name: SysEnt
* @Description:
* @CreatedDate: 2024/9/20 3:02
* @FilePath: com.muyu.system.service.impl
*/
@Slf4j
@Service
public class SysEntServiceImpl extends ServiceImpl<SysEntMapper, SysEnt>
implements SysEntService {
@Resource
private SysEntMapper mapper;
@Override
public List<SysEnt> getList(SysEnt sysEnt) {
return this.list(new LambdaQueryWrapper<>());
}
}

View File

@ -3,6 +3,7 @@ package com.muyu.system.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.constant.UserConstants;
import com.muyu.common.core.exception.ServiceException;
import com.muyu.common.core.utils.ServletUtils;
import com.muyu.common.core.utils.SpringUtils;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.common.core.utils.bean.BeanValidators;
@ -16,14 +17,15 @@ import com.muyu.system.domain.SysUserRole;
import com.muyu.system.mapper.*;
import com.muyu.system.service.SysUserService;
import com.muyu.system.service.SysConfigService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Validator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -36,19 +38,19 @@ import java.util.stream.Collectors;
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
@Autowired
@Resource
protected Validator validator;
@Autowired
@Resource
private SysUserMapper userMapper;
@Autowired
@Resource
private SysRoleMapper roleMapper;
@Autowired
@Resource
private SysPostMapper postMapper;
@Autowired
@Resource
private SysUserRoleMapper userRoleMapper;
@Autowired
@Resource
private SysUserPostMapper userPostMapper;
@Autowired
@Resource
private SysConfigService configService;
/**
@ -98,8 +100,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
* @return
*/
@Override
public SysUser selectUserByUserName (String userName) {
return userMapper.selectUserByUserName(userName);
public SysUser selectUserByUserName (String firmCode, String userName) {
return userMapper.selectUserByUserName(firmCode, userName);
}
/**
@ -463,7 +465,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
for (SysUser user : userList) {
try {
// 验证是否存在这个用户
SysUser u = userMapper.selectUserByUserName(user.getUserName());
String firmCode = SecurityUtils.getSaasKey();
SysUser u = userMapper.selectUserByUserName(firmCode, user.getUserName());
if (StringUtils.isNull(u)) {
BeanValidators.validateWithException(validator, user);
user.setPassword(SecurityUtils.encryptPassword(password));
@ -500,4 +504,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
return successMsg.toString();
}
@Override
public List<SysUser> selectCompanyList() {
return userMapper.selectCompanyList();
}
}

View File

@ -4,10 +4,10 @@ server:
# nacos线上地址
nacos:
addr: 106.54.193.225:8848
addr: 47.116.173.119:8848
user-name: nacos
password: nacos
namespace: one
namespace: one-saas
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
# Spring
spring:
@ -53,8 +53,7 @@ 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}
# rabbit 配置文件
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
logging:
level:
com.muyu.system.mapper: DEBUG

View File

@ -8,6 +8,7 @@
<id property="deptId" column="dept_id"/>
<result property="parentId" column="parent_id"/>
<result property="ancestors" column="ancestors"/>
<result property="firmCode" column="firm_code"/>
<result property="deptName" column="dept_name"/>
<result property="orderNum" column="order_num"/>
<result property="leader" column="leader"/>
@ -26,6 +27,7 @@
select d.dept_id,
d.parent_id,
d.ancestors,
d.firm_code,
d.dept_name,
d.order_num,
d.leader,
@ -44,6 +46,9 @@
<if test="deptId != null and deptId != 0">
AND dept_id = #{deptId}
</if>
<if test="firmCode != null and firmCode != ''">
AND firm_code = #{firmCode}
</if>
<if test="parentId != null and parentId != 0">
AND parent_id = #{parentId}
</if>
@ -113,6 +118,7 @@
insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="parentId != null and parentId != 0">parent_id,</if>
<if test="firmCode != null and firmCode != 0">firm_code,</if>
<if test="deptName != null and deptName != ''">dept_name,</if>
<if test="ancestors != null and ancestors != ''">ancestors,</if>
<if test="orderNum != null">order_num,</if>
@ -126,6 +132,7 @@
<if test="deptId != null and deptId != 0">#{deptId},</if>
<if test="parentId != null and parentId != 0">#{parentId},</if>
<if test="deptName != null and deptName != ''">#{deptName},</if>
<if test="firmCode != null and firmCode != ''">#{firmCode},</if>
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
<if test="orderNum != null">#{orderNum},</if>
<if test="leader != null and leader != ''">#{leader},</if>
@ -141,6 +148,7 @@
update sys_dept
<set>
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
<if test="firmCode != null and firmCode != ''">firm_code = #{firmCode},</if>
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.system.mapper.SysEntMapper">
</mapper>

View File

@ -7,6 +7,7 @@
<resultMap type="com.muyu.common.system.domain.SysUser" id="SysUserResult">
<id property="userId" column="user_id"/>
<result property="deptId" column="dept_id"/>
<result property="firmCode" column="firm_code"/>
<result property="userName" column="user_name"/>
<result property="nickName" column="nick_name"/>
<result property="email" column="email"/>
@ -49,6 +50,7 @@
<sql id="selectUserVo">
select u.user_id,
u.dept_id,
u.firm_code,
u.user_name,
u.nick_name,
u.email,
@ -83,8 +85,8 @@
</sql>
<select id="selectUserList" parameterType="com.muyu.common.system.domain.SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user
select u.user_id, u.dept_id, u.nick_name,u.firm_code, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
u.del_flag,u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user
u
left join sys_dept d on u.dept_id = d.dept_id
where u.del_flag = '0'
@ -115,7 +117,7 @@
</select>
<select id="selectAllocatedList" parameterType="com.muyu.common.system.domain.SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
select distinct u.user_id, u.dept_id,u.firm_code, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
@ -132,7 +134,7 @@
</select>
<select id="selectUnallocatedList" parameterType="com.muyu.common.system.domain.SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
select distinct u.user_id, u.dept_id,u.firm_code, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
@ -152,7 +154,7 @@
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.user_name = #{userName} and u.del_flag = '0'
where u.firm_code = #{firmCode} and u.user_name = #{userName} and u.del_flag = '0'
</select>
<select id="selectUserById" parameterType="Long" resultMap="SysUserResult">
@ -184,11 +186,16 @@
limit 1
</select>
<select id="selectCompanyList" resultType="com.muyu.common.system.domain.SysUser">
select * from sys_user
</select>
<insert id="insertUser" parameterType="com.muyu.common.system.domain.SysUser" useGeneratedKeys="true" keyProperty="userId">
insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if>
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="firmCode != null and firmCode != ''">firm_code,</if>
<if test="nickName != null and nickName != ''">nick_name,</if>
<if test="email != null and email != ''">email,</if>
<if test="avatar != null and avatar != ''">avatar,</if>
@ -203,6 +210,7 @@
<if test="userId != null and userId != ''">#{userId},</if>
<if test="deptId != null and deptId != ''">#{deptId},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="firmCode != null and firmCode != ''">#{firmCode},</if>
<if test="nickName != null and nickName != ''">#{nickName},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="avatar != null and avatar != ''">#{avatar},</if>
@ -221,6 +229,7 @@
<set>
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="firmCode != null and firmCode != ''">firm_code = #{firmCode},</if>
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
<if test="email != null ">email = #{email},</if>
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>

View File

@ -4,10 +4,10 @@ server:
# nacos线上地址
nacos:
addr: 106.54.193.225:8848
addr: 47.116.173.119:8848
user-name: nacos
password: nacos
namespace: one
namespace: one-saas
# Spring
spring:

13
pom.xml
View File

@ -42,11 +42,17 @@
<hutool.version>5.8.27</hutool.version>
<knife4j-openapi3.version>4.1.0</knife4j-openapi3.version>
<xxl-job-core.version>2.4.1</xxl-job-core.version>
<dynamic.datasource.version>4.2.0</dynamic.datasource.version>
</properties>
<!-- 依赖声明 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>${dynamic.datasource.version}</version>
</dependency>
<!-- SpringBoot 依赖配置 -->
<dependency>
<groupId>org.springframework.boot</groupId>
@ -266,6 +272,12 @@
<artifactId>cloud-common-rabbit</artifactId>
<version>${muyu.version}</version>
</dependency>
<dependency>
<groupId>com.muyu</groupId>
<artifactId>cloud-common-saas</artifactId>
<version>${muyu.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -275,6 +287,7 @@
<module>cloud-visual</module>
<module>cloud-modules</module>
<module>cloud-common</module>
<module>cloud-firm</module>
</modules>
<packaging>pom</packaging>

View File

@ -5,3 +5,4 @@ docker run --name xxl-job-admin -d \
-e PARAMS="--spring.config.additional-location=/config/application.properties" \
-v ./log:/data/applogs \
xuxueli/xxl-job-admin:2.4.1