update 2021-01-20
This commit is contained in:
commit
a72dc929be
|
|
@ -0,0 +1,7 @@
|
||||||
|
#! /bin/bash
|
||||||
|
for bootJar in $(find . -name "project-*.jar")
|
||||||
|
|
||||||
|
do
|
||||||
|
./$bootJar &
|
||||||
|
|
||||||
|
done
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# 远程机器上程序发布目录 user@ip:/dir
|
||||||
|
remote_dist=$1
|
||||||
|
if [[ $remote_dist ]];then
|
||||||
|
|
||||||
|
scp -r ./auth-boot/build/libs/project-auth-boot-*.jar $remote_dist/auth &
|
||||||
|
scp -r ./file-boot/build/libs/project-file-boot-*.jar $remote_dist/file &
|
||||||
|
scp -r ./gateway-boot/build/libs/project-gateway-boot-*.jar $remote_dist/gateway &
|
||||||
|
scp -r ./gen-boot/build/libs/project-gen-boot-*.jar $remote_dist/gen &
|
||||||
|
scp -r ./job-boot/build/libs/project-job-boot-*.jar $remote_dist/job &
|
||||||
|
scp -r ./monitor-boot/build/libs/project-monitor-boot-*.jar $remote_dist/monitor &
|
||||||
|
scp -r ./system-boot/build/libs/project-system-boot-*.jar $remote_dist/system &
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
docker network rm fastdfs-net
|
||||||
|
docker network create fastdfs-net
|
||||||
|
|
||||||
|
docker run -dit --network=fastdfs-net --restart=always --name=fdfs-tracker \
|
||||||
|
-v /var/fdfs/tracker:/var/fdfs \
|
||||||
|
ygqygq2/fastdfs-nginx:latest tracker
|
||||||
|
|
||||||
|
docker run -dit --network=fastdfs-net --restart=always --name=fdfs-storage0 \
|
||||||
|
-e TRACKER_SERVER=tracker:22122 -v /var/fdfs/storage0:/var/fdfs \
|
||||||
|
ygqygq2/fastdfs-nginx:latest storage
|
||||||
|
|
||||||
|
docker run -dit --network=fastdfs-net --restart=always --name=fdfs-storage1 \
|
||||||
|
-e TRACKER_SERVER=tracker:22122 -v /var/fdfs/storage1:/var/fdfs \
|
||||||
|
ygqygq2/fastdfs-nginx:latest storage
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
docker rm -f nginx-latest
|
||||||
|
docker run --name=nginx-latest --restart=always -p 80:80 -v /opt/pscada-online/nginx-conf/:/etc/nginx/ -v /var/logs/nginx:/var/logs/nginx -v /opt/pscada-online/www:/opt/pscada-online/www -e TZ="Asia/Shanghai" -d nginx
|
||||||
|
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
docker rm -f prtainer-latest
|
||||||
|
docker run -itd -p 9000:9000 -e TZ="Asia/Shanghai" \
|
||||||
|
--name prtainer-latest --restart=always \
|
||||||
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
|
portainer/portainer-ce
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
#! /bin/bash
|
||||||
|
docker rm -f redis-6.0
|
||||||
|
docker run --name=redis-6.0 --restart=always -itd -v /opt/pscada-online/redis-conf/redis.conf:/etc/redis/redis.conf -p 6379:6379 redis
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
docker rm -f sentinel-dashboard
|
||||||
|
|
||||||
|
docker run --name=sentinel-dashboard --restart=always -e TZ="Asia/Shanghai" -p 9002:8858 -d bladex/sentinel-dashboard:latest
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
#! /bin/bash
|
|
||||||
for dir in $(ls .)
|
|
||||||
do
|
|
||||||
if [[ -f $dir/project-*.jar ]];then
|
|
||||||
./$dir/project-*.jar &
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
#! /bin/bash
|
|
||||||
docker rm -f redis-6.0
|
|
||||||
|
|
||||||
#项目程序部署目录
|
|
||||||
project=$1
|
|
||||||
docker run --name=redis-6.0 --restart=always -itd -v ${project}/redis-conf/redis.conf:/etc/redis/redis.conf -p 6379:6379 redis
|
|
||||||
30
publish.sh
30
publish.sh
|
|
@ -3,25 +3,25 @@
|
||||||
# 使用方法: ./publish.sh 版本号.
|
# 使用方法: ./publish.sh 版本号.
|
||||||
# git pull; git add . ;git commit -m " 发布版本 $*" ; git push
|
# git pull; git add . ;git commit -m " 发布版本 $*" ; git push
|
||||||
|
|
||||||
gradleArgs="clean publish -DbuildProduct=true -DreleaseVersion=$1"
|
gradleArgs=" -s clean publish -DbuildProduct=true -DreleaseVersion=$1 -DdevVersion=$1"
|
||||||
|
|
||||||
|
|
||||||
# 发布公共模块,必须按照下列顺序 编译发布。
|
# 发布公共模块,必须按照下列顺序 编译发布。
|
||||||
gradle $gradleArgs -b ./ruoyi-common/ruoyi-common-core/build.gradle -s
|
gradle $gradleArgs -b ./ruoyi-common/ruoyi-common-core/build.gradle
|
||||||
gradle $gradleArgs -b ./ruoyi-api/ruoyi-api-system/build.gradle -s
|
gradle $gradleArgs -b ./ruoyi-api/ruoyi-api-system/build.gradle
|
||||||
gradle $gradleArgs -b ./ruoyi-common/ruoyi-common-redis/build.gradle -s
|
gradle $gradleArgs -b ./ruoyi-common/ruoyi-common-redis/build.gradle
|
||||||
gradle $gradleArgs -b ./ruoyi-common/ruoyi-common-security/build.gradle -s
|
gradle $gradleArgs -b ./ruoyi-common/ruoyi-common-security/build.gradle
|
||||||
gradle $gradleArgs -b ./ruoyi-common/ruoyi-common-log/build.gradle -s
|
gradle $gradleArgs -b ./ruoyi-common/ruoyi-common-log/build.gradle
|
||||||
gradle $gradleArgs -b ./ruoyi-common/ruoyi-common-datascope/build.gradle -s
|
gradle $gradleArgs -b ./ruoyi-common/ruoyi-common-datascope/build.gradle
|
||||||
gradle $gradleArgs -b ./ruoyi-common/ruoyi-common-swagger/build.gradle -s
|
gradle $gradleArgs -b ./ruoyi-common/ruoyi-common-swagger/build.gradle
|
||||||
|
|
||||||
|
|
||||||
### 六个 微服务依赖, monitor 不需要发布。
|
### 六个 微服务依赖, monitor 不需要发布。
|
||||||
gradle $gradleArgs -b ./ruoyi-auth/build.gradle -s
|
gradle $gradleArgs -b ./ruoyi-auth/build.gradle
|
||||||
gradle $gradleArgs -b ./ruoyi-gateway/build.gradle -s
|
gradle $gradleArgs -b ./ruoyi-gateway/build.gradle
|
||||||
gradle $gradleArgs -b ./ruoyi-modules/ruoyi-system/build.gradle -s
|
gradle $gradleArgs -b ./ruoyi-modules/ruoyi-system/build.gradle
|
||||||
gradle $gradleArgs -b ./ruoyi-modules/ruoyi-file/build.gradle -s
|
gradle $gradleArgs -b ./ruoyi-modules/ruoyi-file/build.gradle
|
||||||
gradle $gradleArgs -b ./ruoyi-modules/ruoyi-gen/build.gradle -s
|
gradle $gradleArgs -b ./ruoyi-modules/ruoyi-gen/build.gradle
|
||||||
gradle $gradleArgs -b ./ruoyi-modules/ruoyi-job/build.gradle -s
|
gradle $gradleArgs -b ./ruoyi-modules/ruoyi-job/build.gradle
|
||||||
|
gradle $gradleArgs -b ./ruoyi-visual/ruoyi-monitor/build.gradle
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
package com.ruoyi.system.api;
|
package com.ruoyi.system.api;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.system.api.domain.SysFile;
|
||||||
|
import com.ruoyi.system.api.factory.RemoteFileFallbackFactory;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestPart;
|
import org.springframework.web.bind.annotation.RequestPart;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.ruoyi.common.core.constant.ServiceNameConstants;
|
|
||||||
import com.ruoyi.common.core.domain.R;
|
|
||||||
import com.ruoyi.system.api.domain.SysFile;
|
|
||||||
import com.ruoyi.system.api.factory.RemoteFileFallbackFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件服务
|
* 文件服务
|
||||||
|
|
@ -16,8 +16,7 @@ import com.ruoyi.system.api.factory.RemoteFileFallbackFactory;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFileFallbackFactory.class)
|
@FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFileFallbackFactory.class)
|
||||||
public interface RemoteFileService
|
public interface RemoteFileService {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 上传文件
|
* 上传文件
|
||||||
*
|
*
|
||||||
|
|
@ -25,5 +24,5 @@ public interface RemoteFileService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
public R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);
|
R<SysFile> upload(@RequestPart(value = "file") MultipartFile file);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
package com.ruoyi.system.api.factory;
|
package com.ruoyi.system.api.factory;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.R;
|
||||||
|
import com.ruoyi.system.api.RemoteFileService;
|
||||||
|
import feign.hystrix.FallbackFactory;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
import com.ruoyi.common.core.domain.R;
|
|
||||||
import com.ruoyi.system.api.RemoteFileService;
|
|
||||||
import com.ruoyi.system.api.domain.SysFile;
|
|
||||||
import feign.hystrix.FallbackFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件服务降级处理
|
* 文件服务降级处理
|
||||||
|
|
@ -15,21 +13,12 @@ import feign.hystrix.FallbackFactory;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileService>
|
public class RemoteFileFallbackFactory implements FallbackFactory<RemoteFileService> {
|
||||||
{
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(RemoteFileFallbackFactory.class);
|
private static final Logger log = LoggerFactory.getLogger(RemoteFileFallbackFactory.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RemoteFileService create(Throwable throwable)
|
public RemoteFileService create(Throwable throwable) {
|
||||||
{
|
|
||||||
log.error("文件服务调用失败:{}", throwable.getMessage());
|
log.error("文件服务调用失败:{}", throwable.getMessage());
|
||||||
return new RemoteFileService()
|
return file -> R.fail("上传文件失败:" + throwable.getMessage());
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public R<SysFile> upload(MultipartFile file)
|
|
||||||
{
|
|
||||||
return R.fail("上传文件失败:" + throwable.getMessage());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,18 @@
|
||||||
package com.ruoyi.common.redis.service;
|
package com.ruoyi.common.redis.service;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.BoundSetOperations;
|
import org.springframework.data.redis.core.*;
|
||||||
import org.springframework.data.redis.core.HashOperations;
|
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.data.redis.core.ValueOperations;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* spring redis 工具类
|
* spring redis 工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
**/
|
**/
|
||||||
@SuppressWarnings(value = { "unchecked", "rawtypes" })
|
|
||||||
@Component
|
@Component
|
||||||
public class RedisService
|
public class RedisService
|
||||||
{
|
{
|
||||||
|
|
@ -31,7 +25,7 @@ public class RedisService
|
||||||
* @param key 缓存的键值
|
* @param key 缓存的键值
|
||||||
* @param value 缓存的值
|
* @param value 缓存的值
|
||||||
*/
|
*/
|
||||||
public <T> void setCacheObject(final String key, final T value)
|
public <T> void setCacheObject(String key, T value)
|
||||||
{
|
{
|
||||||
redisTemplate.opsForValue().set(key, value);
|
redisTemplate.opsForValue().set(key, value);
|
||||||
}
|
}
|
||||||
|
|
@ -44,7 +38,7 @@ public class RedisService
|
||||||
* @param timeout 时间
|
* @param timeout 时间
|
||||||
* @param timeUnit 时间颗粒度
|
* @param timeUnit 时间颗粒度
|
||||||
*/
|
*/
|
||||||
public <T> void setCacheObject(final String key, final T value, final Long timeout, final TimeUnit timeUnit)
|
public <T> void setCacheObject(String key, T value, Long timeout, TimeUnit timeUnit)
|
||||||
{
|
{
|
||||||
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
|
redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +50,7 @@ public class RedisService
|
||||||
* @param timeout 超时时间
|
* @param timeout 超时时间
|
||||||
* @return true=设置成功;false=设置失败
|
* @return true=设置成功;false=设置失败
|
||||||
*/
|
*/
|
||||||
public boolean expire(final String key, final long timeout)
|
public boolean expire(String key, long timeout)
|
||||||
{
|
{
|
||||||
return expire(key, timeout, TimeUnit.SECONDS);
|
return expire(key, timeout, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
@ -69,7 +63,7 @@ public class RedisService
|
||||||
* @param unit 时间单位
|
* @param unit 时间单位
|
||||||
* @return true=设置成功;false=设置失败
|
* @return true=设置成功;false=设置失败
|
||||||
*/
|
*/
|
||||||
public boolean expire(final String key, final long timeout, final TimeUnit unit)
|
public boolean expire(String key, long timeout, TimeUnit unit)
|
||||||
{
|
{
|
||||||
return redisTemplate.expire(key, timeout, unit);
|
return redisTemplate.expire(key, timeout, unit);
|
||||||
}
|
}
|
||||||
|
|
@ -80,7 +74,7 @@ public class RedisService
|
||||||
* @param key 缓存键值
|
* @param key 缓存键值
|
||||||
* @return 缓存键值对应的数据
|
* @return 缓存键值对应的数据
|
||||||
*/
|
*/
|
||||||
public <T> T getCacheObject(final String key)
|
public <T> T getCacheObject(String key)
|
||||||
{
|
{
|
||||||
ValueOperations<String, T> operation = redisTemplate.opsForValue();
|
ValueOperations<String, T> operation = redisTemplate.opsForValue();
|
||||||
return operation.get(key);
|
return operation.get(key);
|
||||||
|
|
@ -91,7 +85,7 @@ public class RedisService
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
public boolean deleteObject(final String key)
|
public boolean deleteObject(String key)
|
||||||
{
|
{
|
||||||
return redisTemplate.delete(key);
|
return redisTemplate.delete(key);
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +96,7 @@ public class RedisService
|
||||||
* @param collection 多个对象
|
* @param collection 多个对象
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public long deleteObject(final Collection collection)
|
public long deleteObject(Collection collection)
|
||||||
{
|
{
|
||||||
return redisTemplate.delete(collection);
|
return redisTemplate.delete(collection);
|
||||||
}
|
}
|
||||||
|
|
@ -114,7 +108,7 @@ public class RedisService
|
||||||
* @param dataList 待缓存的List数据
|
* @param dataList 待缓存的List数据
|
||||||
* @return 缓存的对象
|
* @return 缓存的对象
|
||||||
*/
|
*/
|
||||||
public <T> long setCacheList(final String key, final List<T> dataList)
|
public <T> long setCacheList(String key, List<T> dataList)
|
||||||
{
|
{
|
||||||
Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
|
Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
|
||||||
return count == null ? 0 : count;
|
return count == null ? 0 : count;
|
||||||
|
|
@ -126,7 +120,7 @@ public class RedisService
|
||||||
* @param key 缓存的键值
|
* @param key 缓存的键值
|
||||||
* @return 缓存键值对应的数据
|
* @return 缓存键值对应的数据
|
||||||
*/
|
*/
|
||||||
public <T> List<T> getCacheList(final String key)
|
public <T> List<T> getCacheList(String key)
|
||||||
{
|
{
|
||||||
return redisTemplate.opsForList().range(key, 0, -1);
|
return redisTemplate.opsForList().range(key, 0, -1);
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +132,7 @@ public class RedisService
|
||||||
* @param dataSet 缓存的数据
|
* @param dataSet 缓存的数据
|
||||||
* @return 缓存数据的对象
|
* @return 缓存数据的对象
|
||||||
*/
|
*/
|
||||||
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)
|
public <T> BoundSetOperations<String, T> setCacheSet(String key, Set<T> dataSet)
|
||||||
{
|
{
|
||||||
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
||||||
Iterator<T> it = dataSet.iterator();
|
Iterator<T> it = dataSet.iterator();
|
||||||
|
|
@ -155,7 +149,7 @@ public class RedisService
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public <T> Set<T> getCacheSet(final String key)
|
public <T> Set<T> getCacheSet(String key)
|
||||||
{
|
{
|
||||||
return redisTemplate.opsForSet().members(key);
|
return redisTemplate.opsForSet().members(key);
|
||||||
}
|
}
|
||||||
|
|
@ -166,7 +160,7 @@ public class RedisService
|
||||||
* @param key
|
* @param key
|
||||||
* @param dataMap
|
* @param dataMap
|
||||||
*/
|
*/
|
||||||
public <T> void setCacheMap(final String key, final Map<String, T> dataMap)
|
public <T> void setCacheMap(String key, Map<String, T> dataMap)
|
||||||
{
|
{
|
||||||
if (dataMap != null) {
|
if (dataMap != null) {
|
||||||
redisTemplate.opsForHash().putAll(key, dataMap);
|
redisTemplate.opsForHash().putAll(key, dataMap);
|
||||||
|
|
@ -179,7 +173,7 @@ public class RedisService
|
||||||
* @param key
|
* @param key
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public <T> Map<String, T> getCacheMap(final String key)
|
public <T> Map<String, T> getCacheMap(String key)
|
||||||
{
|
{
|
||||||
return redisTemplate.opsForHash().entries(key);
|
return redisTemplate.opsForHash().entries(key);
|
||||||
}
|
}
|
||||||
|
|
@ -191,7 +185,7 @@ public class RedisService
|
||||||
* @param hKey Hash键
|
* @param hKey Hash键
|
||||||
* @param value 值
|
* @param value 值
|
||||||
*/
|
*/
|
||||||
public <T> void setCacheMapValue(final String key, final String hKey, final T value)
|
public <T> void setCacheMapValue(String key, String hKey, T value)
|
||||||
{
|
{
|
||||||
redisTemplate.opsForHash().put(key, hKey, value);
|
redisTemplate.opsForHash().put(key, hKey, value);
|
||||||
}
|
}
|
||||||
|
|
@ -203,7 +197,7 @@ public class RedisService
|
||||||
* @param hKey Hash键
|
* @param hKey Hash键
|
||||||
* @return Hash中的对象
|
* @return Hash中的对象
|
||||||
*/
|
*/
|
||||||
public <T> T getCacheMapValue(final String key, final String hKey)
|
public <T> T getCacheMapValue(String key, String hKey)
|
||||||
{
|
{
|
||||||
HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
|
HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
|
||||||
return opsForHash.get(key, hKey);
|
return opsForHash.get(key, hKey);
|
||||||
|
|
@ -216,7 +210,7 @@ public class RedisService
|
||||||
* @param hKeys Hash键集合
|
* @param hKeys Hash键集合
|
||||||
* @return Hash对象集合
|
* @return Hash对象集合
|
||||||
*/
|
*/
|
||||||
public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys)
|
public <T> List<T> getMultiCacheMapValue(String key, Collection<Object> hKeys)
|
||||||
{
|
{
|
||||||
return redisTemplate.opsForHash().multiGet(key, hKeys);
|
return redisTemplate.opsForHash().multiGet(key, hKeys);
|
||||||
}
|
}
|
||||||
|
|
@ -227,8 +221,31 @@ public class RedisService
|
||||||
* @param pattern 字符串前缀
|
* @param pattern 字符串前缀
|
||||||
* @return 对象列表
|
* @return 对象列表
|
||||||
*/
|
*/
|
||||||
public Collection<String> keys(final String pattern)
|
@Deprecated
|
||||||
|
public Collection<String> keys(String pattern)
|
||||||
{
|
{
|
||||||
return redisTemplate.keys(pattern);
|
return redisTemplate.keys(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 非阻塞方式模糊匹配keys
|
||||||
|
*
|
||||||
|
* @param matchKey
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Set<String> scan(String matchKey) {
|
||||||
|
Set<String> keys = (Set<String>) redisTemplate.execute((RedisCallback<Set<String>>) connection -> {
|
||||||
|
Set<String> keysTmp = new HashSet<>();
|
||||||
|
Cursor<byte[]> cursor = connection.scan(new ScanOptions.ScanOptionsBuilder().match(matchKey).count(1000).build());
|
||||||
|
while (cursor.hasNext()) {
|
||||||
|
keysTmp.add(new String(cursor.next()));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
cursor.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
return keysTmp;
|
||||||
|
});
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../../build-config/publish.sh
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
package com.ruoyi.file.service;
|
package com.ruoyi.file.service;
|
||||||
|
|
||||||
|
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
||||||
|
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import com.github.tobato.fastdfs.domain.fdfs.StorePath;
|
|
||||||
import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FastDFS 文件存储
|
* FastDFS 文件存储
|
||||||
|
|
@ -14,8 +15,8 @@ import com.github.tobato.fastdfs.service.FastFileStorageClient;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class FastDfsSysFileServiceImpl implements ISysFileService
|
@ConfigurationProperties(prefix = "fdfs")
|
||||||
{
|
public class FastDfsSysFileServiceImpl implements ISysFileService {
|
||||||
/**
|
/**
|
||||||
* 域名或本机访问地址
|
* 域名或本机访问地址
|
||||||
*/
|
*/
|
||||||
|
|
@ -33,8 +34,7 @@ public class FastDfsSysFileServiceImpl implements ISysFileService
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String uploadFile(MultipartFile file) throws Exception
|
public String uploadFile(MultipartFile file) throws Exception {
|
||||||
{
|
|
||||||
StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(),
|
StorePath storePath = storageClient.uploadFile(file.getInputStream(), file.getSize(),
|
||||||
FilenameUtils.getExtension(file.getOriginalFilename()), null);
|
FilenameUtils.getExtension(file.getOriginalFilename()), null);
|
||||||
return domain + "/" + storePath.getFullPath();
|
return domain + "/" + storePath.getFullPath();
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,18 @@
|
||||||
package com.ruoyi.file.service;
|
package com.ruoyi.file.service;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.context.annotation.Primary;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
import com.ruoyi.file.utils.FileUploadUtils;
|
import com.ruoyi.file.utils.FileUploadUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 本地文件存储
|
* 本地文件存储
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Primary
|
|
||||||
@Service
|
//@Service
|
||||||
public class LocalSysFileServiceImpl implements ISysFileService
|
//@ConfigurationProperties(prefix = "fdfs")
|
||||||
{
|
public class LocalSysFileServiceImpl implements ISysFileService {
|
||||||
/**
|
/**
|
||||||
* 资源映射路径 前缀
|
* 资源映射路径 前缀
|
||||||
*/
|
*/
|
||||||
|
|
@ -40,8 +38,8 @@ public class LocalSysFileServiceImpl implements ISysFileService
|
||||||
* @return 访问地址
|
* @return 访问地址
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public String uploadFile(MultipartFile file) throws Exception
|
@Override
|
||||||
{
|
public String uploadFile(MultipartFile file) throws Exception {
|
||||||
String name = FileUploadUtils.upload(localFilePath, file);
|
String name = FileUploadUtils.upload(localFilePath, file);
|
||||||
String url = domain + localFilePrefix + name;
|
String url = domain + localFilePrefix + name;
|
||||||
return url;
|
return url;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,13 @@
|
||||||
package com.ruoyi.file.service;
|
package com.ruoyi.file.service;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
import com.ruoyi.file.config.MinioConfig;
|
import com.ruoyi.file.config.MinioConfig;
|
||||||
import com.ruoyi.file.utils.FileUploadUtils;
|
import com.ruoyi.file.utils.FileUploadUtils;
|
||||||
import io.minio.MinioClient;
|
import io.minio.MinioClient;
|
||||||
import io.minio.PutObjectArgs;
|
import io.minio.PutObjectArgs;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minio 文件存储
|
* Minio 文件存储
|
||||||
|
|
@ -14,8 +15,8 @@ import io.minio.PutObjectArgs;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class MinioSysFileServiceImpl implements ISysFileService
|
@Primary
|
||||||
{
|
public class MinioSysFileServiceImpl implements ISysFileService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MinioConfig minioConfig;
|
private MinioConfig minioConfig;
|
||||||
|
|
||||||
|
|
@ -29,8 +30,8 @@ public class MinioSysFileServiceImpl implements ISysFileService
|
||||||
* @return 访问地址
|
* @return 访问地址
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public String uploadFile(MultipartFile file) throws Exception
|
@Override
|
||||||
{
|
public String uploadFile(MultipartFile file) throws Exception {
|
||||||
String fileName = FileUploadUtils.extractFilename(file);
|
String fileName = FileUploadUtils.extractFilename(file);
|
||||||
PutObjectArgs args = PutObjectArgs.builder()
|
PutObjectArgs args = PutObjectArgs.builder()
|
||||||
.bucket(minioConfig.getBucketName())
|
.bucket(minioConfig.getBucketName())
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,8 @@ dependencies {
|
||||||
implementation "org.apache.commons:commons-lang3:3.11"
|
implementation "org.apache.commons:commons-lang3:3.11"
|
||||||
implementation "io.springfox:springfox-swagger-ui:2.9.2"
|
implementation "io.springfox:springfox-swagger-ui:2.9.2"
|
||||||
implementation "org.mariadb.jdbc:mariadb-java-client:2.7.1"
|
implementation "org.mariadb.jdbc:mariadb-java-client:2.7.1"
|
||||||
implementation "org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4"
|
// implementation "org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4"
|
||||||
|
implementation 'com.baomidou:mybatis-plus-boot-starter:3.4.1'
|
||||||
implementation "com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config:${alibabaCloud}"
|
implementation "com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-config:${alibabaCloud}"
|
||||||
implementation "com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery:${alibabaCloud}"
|
implementation "com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery:${alibabaCloud}"
|
||||||
implementation "com.alibaba.cloud:spring-cloud-starter-alibaba-sentinel:${alibabaCloud}"
|
implementation "com.alibaba.cloud:spring-cloud-starter-alibaba-sentinel:${alibabaCloud}"
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
package com.ruoyi.gen;
|
package com.ruoyi.gen;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
|
||||||
import org.springframework.cloud.client.SpringCloudApplication;
|
|
||||||
import com.ruoyi.common.security.annotation.EnableCustomConfig;
|
import com.ruoyi.common.security.annotation.EnableCustomConfig;
|
||||||
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
|
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
|
||||||
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
|
import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.cloud.client.SpringCloudApplication;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码生成
|
* 代码生成
|
||||||
|
|
@ -15,10 +15,8 @@ import com.ruoyi.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
@EnableCustomSwagger2
|
@EnableCustomSwagger2
|
||||||
@EnableRyFeignClients
|
@EnableRyFeignClients
|
||||||
@SpringCloudApplication
|
@SpringCloudApplication
|
||||||
public class RuoYiGenApplication
|
public class RuoYiGenApplication {
|
||||||
{
|
public static void main(String[] args) {
|
||||||
public static void main(String[] args)
|
|
||||||
{
|
|
||||||
SpringApplication.run(RuoYiGenApplication.class, args);
|
SpringApplication.run(RuoYiGenApplication.class, args);
|
||||||
System.out.println("(♥◠‿◠)ノ゙ 代码生成模块启动成功 ლ(´ڡ`ლ)゙ \n" +
|
System.out.println("(♥◠‿◠)ノ゙ 代码生成模块启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||||
" .-------. ____ __ \n" +
|
" .-------. ____ __ \n" +
|
||||||
|
|
|
||||||
|
|
@ -10,57 +10,56 @@ import org.springframework.stereotype.Component;
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@ConfigurationProperties(prefix = "gen")
|
@ConfigurationProperties(prefix = "gen")
|
||||||
public class GenConfig
|
public class GenConfig {
|
||||||
{
|
/**
|
||||||
/** 作者 */
|
* 作者
|
||||||
|
*/
|
||||||
public static String author;
|
public static String author;
|
||||||
|
|
||||||
/** 生成包路径 */
|
/**
|
||||||
|
* 生成包路径
|
||||||
|
*/
|
||||||
public static String packageName;
|
public static String packageName;
|
||||||
|
|
||||||
/** 自动去除表前缀,默认是false */
|
/**
|
||||||
|
* 自动去除表前缀,默认是false
|
||||||
|
*/
|
||||||
public static boolean autoRemovePre;
|
public static boolean autoRemovePre;
|
||||||
|
|
||||||
/** 表前缀(类名不会包含表前缀) */
|
/**
|
||||||
|
* 表前缀(类名不会包含表前缀)
|
||||||
|
*/
|
||||||
public static String tablePrefix;
|
public static String tablePrefix;
|
||||||
|
|
||||||
public static String getAuthor()
|
public static String getAuthor() {
|
||||||
{
|
|
||||||
return author;
|
return author;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthor(String author)
|
public void setAuthor(String author) {
|
||||||
{
|
|
||||||
GenConfig.author = author;
|
GenConfig.author = author;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPackageName()
|
public static String getPackageName() {
|
||||||
{
|
|
||||||
return packageName;
|
return packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPackageName(String packageName)
|
public void setPackageName(String packageName) {
|
||||||
{
|
|
||||||
GenConfig.packageName = packageName;
|
GenConfig.packageName = packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getAutoRemovePre()
|
public static boolean getAutoRemovePre() {
|
||||||
{
|
|
||||||
return autoRemovePre;
|
return autoRemovePre;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAutoRemovePre(boolean autoRemovePre)
|
public void setAutoRemovePre(boolean autoRemovePre) {
|
||||||
{
|
|
||||||
GenConfig.autoRemovePre = autoRemovePre;
|
GenConfig.autoRemovePre = autoRemovePre;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTablePrefix()
|
public static String getTablePrefix() {
|
||||||
{
|
|
||||||
return tablePrefix;
|
return tablePrefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTablePrefix(String tablePrefix)
|
public void setTablePrefix(String tablePrefix) {
|
||||||
{
|
|
||||||
GenConfig.tablePrefix = tablePrefix;
|
GenConfig.tablePrefix = tablePrefix;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,5 @@
|
||||||
package com.ruoyi.gen.controller;
|
package com.ruoyi.gen.controller;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import javax.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.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
|
@ -27,6 +11,16 @@ import com.ruoyi.gen.domain.GenTable;
|
||||||
import com.ruoyi.gen.domain.GenTableColumn;
|
import com.ruoyi.gen.domain.GenTableColumn;
|
||||||
import com.ruoyi.gen.service.IGenTableColumnService;
|
import com.ruoyi.gen.service.IGenTableColumnService;
|
||||||
import com.ruoyi.gen.service.IGenTableService;
|
import com.ruoyi.gen.service.IGenTableService;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码生成 操作处理
|
* 代码生成 操作处理
|
||||||
|
|
@ -35,8 +29,7 @@ import com.ruoyi.gen.service.IGenTableService;
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/gen")
|
@RequestMapping("/gen")
|
||||||
@RestController
|
@RestController
|
||||||
public class GenController extends BaseController
|
public class GenController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IGenTableService genTableService;
|
private IGenTableService genTableService;
|
||||||
|
|
||||||
|
|
@ -48,8 +41,7 @@ public class GenController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(hasPermi = "tool:gen:list")
|
@PreAuthorize(hasPermi = "tool:gen:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo genList(GenTable genTable)
|
public TableDataInfo genList(GenTable genTable) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<GenTable> list = genTableService.selectGenTableList(genTable);
|
List<GenTable> list = genTableService.selectGenTableList(genTable);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
|
|
@ -60,8 +52,7 @@ public class GenController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(hasPermi = "tool:gen:query")
|
@PreAuthorize(hasPermi = "tool:gen:query")
|
||||||
@GetMapping(value = "/{talbleId}")
|
@GetMapping(value = "/{talbleId}")
|
||||||
public AjaxResult getInfo(@PathVariable Long talbleId)
|
public AjaxResult getInfo(@PathVariable Long talbleId) {
|
||||||
{
|
|
||||||
GenTable table = genTableService.selectGenTableById(talbleId);
|
GenTable table = genTableService.selectGenTableById(talbleId);
|
||||||
List<GenTable> tables = genTableService.selectGenTableAll();
|
List<GenTable> tables = genTableService.selectGenTableAll();
|
||||||
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
|
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(talbleId);
|
||||||
|
|
@ -77,8 +68,7 @@ public class GenController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(hasPermi = "tool:gen:list")
|
@PreAuthorize(hasPermi = "tool:gen:list")
|
||||||
@GetMapping("/db/list")
|
@GetMapping("/db/list")
|
||||||
public TableDataInfo dataList(GenTable genTable)
|
public TableDataInfo dataList(GenTable genTable) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<GenTable> list = genTableService.selectDbTableList(genTable);
|
List<GenTable> list = genTableService.selectDbTableList(genTable);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
|
|
@ -88,8 +78,7 @@ public class GenController extends BaseController
|
||||||
* 查询数据表字段列表
|
* 查询数据表字段列表
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/column/{talbleId}")
|
@GetMapping(value = "/column/{talbleId}")
|
||||||
public TableDataInfo columnList(Long tableId)
|
public TableDataInfo columnList(Long tableId) {
|
||||||
{
|
|
||||||
TableDataInfo dataInfo = new TableDataInfo();
|
TableDataInfo dataInfo = new TableDataInfo();
|
||||||
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
|
List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
|
||||||
dataInfo.setRows(list);
|
dataInfo.setRows(list);
|
||||||
|
|
@ -103,8 +92,7 @@ public class GenController extends BaseController
|
||||||
@PreAuthorize(hasPermi = "tool:gen:list")
|
@PreAuthorize(hasPermi = "tool:gen:list")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
|
||||||
@PostMapping("/importTable")
|
@PostMapping("/importTable")
|
||||||
public AjaxResult importTableSave(String tables)
|
public AjaxResult importTableSave(String tables) {
|
||||||
{
|
|
||||||
String[] tableNames = Convert.toStrArray(tables);
|
String[] tableNames = Convert.toStrArray(tables);
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
|
||||||
|
|
@ -118,8 +106,7 @@ public class GenController extends BaseController
|
||||||
@PreAuthorize(hasPermi = "tool:gen:edit")
|
@PreAuthorize(hasPermi = "tool:gen:edit")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public AjaxResult editSave(@Validated @RequestBody GenTable genTable)
|
public AjaxResult editSave(@Validated @RequestBody GenTable genTable) {
|
||||||
{
|
|
||||||
genTableService.validateEdit(genTable);
|
genTableService.validateEdit(genTable);
|
||||||
genTableService.updateGenTable(genTable);
|
genTableService.updateGenTable(genTable);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
|
|
@ -131,8 +118,7 @@ public class GenController extends BaseController
|
||||||
@PreAuthorize(hasPermi = "tool:gen:remove")
|
@PreAuthorize(hasPermi = "tool:gen:remove")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.DELETE)
|
@Log(title = "代码生成", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping("/{tableIds}")
|
@DeleteMapping("/{tableIds}")
|
||||||
public AjaxResult remove(@PathVariable Long[] tableIds)
|
public AjaxResult remove(@PathVariable Long[] tableIds) {
|
||||||
{
|
|
||||||
genTableService.deleteGenTableByIds(tableIds);
|
genTableService.deleteGenTableByIds(tableIds);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
@ -142,8 +128,7 @@ public class GenController extends BaseController
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(hasPermi = "tool:gen:preview")
|
@PreAuthorize(hasPermi = "tool:gen:preview")
|
||||||
@GetMapping("/preview/{tableId}")
|
@GetMapping("/preview/{tableId}")
|
||||||
public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException
|
public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException {
|
||||||
{
|
|
||||||
Map<String, String> dataMap = genTableService.previewCode(tableId);
|
Map<String, String> dataMap = genTableService.previewCode(tableId);
|
||||||
return AjaxResult.success(dataMap);
|
return AjaxResult.success(dataMap);
|
||||||
}
|
}
|
||||||
|
|
@ -154,8 +139,7 @@ public class GenController extends BaseController
|
||||||
@PreAuthorize(hasPermi = "tool:gen:code")
|
@PreAuthorize(hasPermi = "tool:gen:code")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
||||||
@GetMapping("/download/{tableName}")
|
@GetMapping("/download/{tableName}")
|
||||||
public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException
|
public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
|
||||||
{
|
|
||||||
byte[] data = genTableService.downloadCode(tableName);
|
byte[] data = genTableService.downloadCode(tableName);
|
||||||
genCode(response, data);
|
genCode(response, data);
|
||||||
}
|
}
|
||||||
|
|
@ -166,8 +150,7 @@ public class GenController extends BaseController
|
||||||
@PreAuthorize(hasPermi = "tool:gen:code")
|
@PreAuthorize(hasPermi = "tool:gen:code")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
||||||
@GetMapping("/genCode/{tableName}")
|
@GetMapping("/genCode/{tableName}")
|
||||||
public AjaxResult genCode(@PathVariable("tableName") String tableName)
|
public AjaxResult genCode(@PathVariable("tableName") String tableName) {
|
||||||
{
|
|
||||||
genTableService.generatorCode(tableName);
|
genTableService.generatorCode(tableName);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
@ -178,8 +161,7 @@ public class GenController extends BaseController
|
||||||
@PreAuthorize(hasPermi = "tool:gen:edit")
|
@PreAuthorize(hasPermi = "tool:gen:edit")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
@Log(title = "代码生成", businessType = BusinessType.UPDATE)
|
||||||
@GetMapping("/synchDb/{tableName}")
|
@GetMapping("/synchDb/{tableName}")
|
||||||
public AjaxResult synchDb(@PathVariable("tableName") String tableName)
|
public AjaxResult synchDb(@PathVariable("tableName") String tableName) {
|
||||||
{
|
|
||||||
genTableService.synchDb(tableName);
|
genTableService.synchDb(tableName);
|
||||||
return AjaxResult.success();
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
@ -190,8 +172,7 @@ public class GenController extends BaseController
|
||||||
@PreAuthorize(hasPermi = "tool:gen:code")
|
@PreAuthorize(hasPermi = "tool:gen:code")
|
||||||
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
@Log(title = "代码生成", businessType = BusinessType.GENCODE)
|
||||||
@GetMapping("/batchGenCode")
|
@GetMapping("/batchGenCode")
|
||||||
public void batchGenCode(HttpServletResponse response, String tables) throws IOException
|
public void batchGenCode(HttpServletResponse response, String tables) throws IOException {
|
||||||
{
|
|
||||||
String[] tableNames = Convert.toStrArray(tables);
|
String[] tableNames = Convert.toStrArray(tables);
|
||||||
byte[] data = genTableService.downloadCode(tableNames);
|
byte[] data = genTableService.downloadCode(tableNames);
|
||||||
genCode(response, data);
|
genCode(response, data);
|
||||||
|
|
@ -200,10 +181,9 @@ public class GenController extends BaseController
|
||||||
/**
|
/**
|
||||||
* 生成zip文件
|
* 生成zip文件
|
||||||
*/
|
*/
|
||||||
private void genCode(HttpServletResponse response, byte[] data) throws IOException
|
private void genCode(HttpServletResponse response, byte[] data) throws IOException {
|
||||||
{
|
|
||||||
response.reset();
|
response.reset();
|
||||||
response.setHeader("Content-Disposition", "attachment; filename=\"ruoyi.zip\"");
|
response.setHeader("Content-Disposition", "attachment; filename=\"code.zip\"");
|
||||||
response.addHeader("Content-Length", "" + data.length);
|
response.addHeader("Content-Length", "" + data.length);
|
||||||
response.setContentType("application/octet-stream; charset=UTF-8");
|
response.setContentType("application/octet-stream; charset=UTF-8");
|
||||||
IOUtils.write(data, response.getOutputStream());
|
IOUtils.write(data, response.getOutputStream());
|
||||||
|
|
|
||||||
|
|
@ -1,367 +1,313 @@
|
||||||
package com.ruoyi.gen.domain;
|
package com.ruoyi.gen.domain;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
import com.ruoyi.common.core.constant.GenConstants;
|
import com.ruoyi.common.core.constant.GenConstants;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务表 gen_table
|
* 业务表 gen_table
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class GenTable extends BaseEntity
|
public class GenTable extends BaseEntity {
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 编号 */
|
/**
|
||||||
|
* 编号
|
||||||
|
*/
|
||||||
private Long tableId;
|
private Long tableId;
|
||||||
|
|
||||||
/** 表名称 */
|
/**
|
||||||
|
* 表名称
|
||||||
|
*/
|
||||||
@NotBlank(message = "表名称不能为空")
|
@NotBlank(message = "表名称不能为空")
|
||||||
private String tableName;
|
private String tableName;
|
||||||
|
|
||||||
/** 表描述 */
|
/**
|
||||||
|
* 表描述
|
||||||
|
*/
|
||||||
@NotBlank(message = "表描述不能为空")
|
@NotBlank(message = "表描述不能为空")
|
||||||
private String tableComment;
|
private String tableComment;
|
||||||
|
|
||||||
/** 关联父表的表名 */
|
/**
|
||||||
private String subTableName;
|
* 实体类名称(首字母大写)
|
||||||
|
*/
|
||||||
/** 本表关联父表的外键名 */
|
|
||||||
private String subTableFkName;
|
|
||||||
|
|
||||||
/** 实体类名称(首字母大写) */
|
|
||||||
@NotBlank(message = "实体类名称不能为空")
|
@NotBlank(message = "实体类名称不能为空")
|
||||||
private String className;
|
private String className;
|
||||||
|
|
||||||
/** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */
|
/**
|
||||||
|
* 使用的模板(crud单表操作 tree树表操作)
|
||||||
|
*/
|
||||||
private String tplCategory;
|
private String tplCategory;
|
||||||
|
|
||||||
/** 生成包路径 */
|
/**
|
||||||
|
* 生成包路径
|
||||||
|
*/
|
||||||
@NotBlank(message = "生成包路径不能为空")
|
@NotBlank(message = "生成包路径不能为空")
|
||||||
private String packageName;
|
private String packageName;
|
||||||
|
|
||||||
/** 生成模块名 */
|
/**
|
||||||
|
* 生成模块名
|
||||||
|
*/
|
||||||
@NotBlank(message = "生成模块名不能为空")
|
@NotBlank(message = "生成模块名不能为空")
|
||||||
private String moduleName;
|
private String moduleName;
|
||||||
|
|
||||||
/** 生成业务名 */
|
/**
|
||||||
|
* 生成业务名
|
||||||
|
*/
|
||||||
@NotBlank(message = "生成业务名不能为空")
|
@NotBlank(message = "生成业务名不能为空")
|
||||||
private String businessName;
|
private String businessName;
|
||||||
|
|
||||||
/** 生成功能名 */
|
/**
|
||||||
|
* 生成功能名
|
||||||
|
*/
|
||||||
@NotBlank(message = "生成功能名不能为空")
|
@NotBlank(message = "生成功能名不能为空")
|
||||||
private String functionName;
|
private String functionName;
|
||||||
|
|
||||||
/** 生成作者 */
|
/**
|
||||||
|
* 生成作者
|
||||||
|
*/
|
||||||
@NotBlank(message = "作者不能为空")
|
@NotBlank(message = "作者不能为空")
|
||||||
private String functionAuthor;
|
private String functionAuthor;
|
||||||
|
|
||||||
/** 生成代码方式(0zip压缩包 1自定义路径) */
|
/**
|
||||||
|
* 生成代码方式(0zip压缩包 1自定义路径)
|
||||||
|
*/
|
||||||
private String genType;
|
private String genType;
|
||||||
|
|
||||||
/** 生成路径(不填默认项目路径) */
|
/**
|
||||||
|
* 生成路径(不填默认项目路径)
|
||||||
|
*/
|
||||||
private String genPath;
|
private String genPath;
|
||||||
|
|
||||||
/** 主键信息 */
|
/**
|
||||||
|
* 主键信息
|
||||||
|
*/
|
||||||
private GenTableColumn pkColumn;
|
private GenTableColumn pkColumn;
|
||||||
|
|
||||||
/** 子表信息 */
|
/**
|
||||||
private GenTable subTable;
|
* 表列信息
|
||||||
|
*/
|
||||||
/** 表列信息 */
|
|
||||||
@Valid
|
@Valid
|
||||||
private List<GenTableColumn> columns;
|
private List<GenTableColumn> columns;
|
||||||
|
|
||||||
/** 其它生成选项 */
|
/**
|
||||||
|
* 其它生成选项
|
||||||
|
*/
|
||||||
private String options;
|
private String options;
|
||||||
|
|
||||||
/** 树编码字段 */
|
/**
|
||||||
|
* 树编码字段
|
||||||
|
*/
|
||||||
private String treeCode;
|
private String treeCode;
|
||||||
|
|
||||||
/** 树父编码字段 */
|
/**
|
||||||
|
* 树父编码字段
|
||||||
|
*/
|
||||||
private String treeParentCode;
|
private String treeParentCode;
|
||||||
|
|
||||||
/** 树名称字段 */
|
/**
|
||||||
|
* 树名称字段
|
||||||
|
*/
|
||||||
private String treeName;
|
private String treeName;
|
||||||
|
|
||||||
/** 上级菜单ID字段 */
|
/**
|
||||||
|
* 上级菜单ID字段
|
||||||
|
*/
|
||||||
private String parentMenuId;
|
private String parentMenuId;
|
||||||
|
|
||||||
/** 上级菜单名称字段 */
|
/**
|
||||||
|
* 上级菜单名称字段
|
||||||
|
*/
|
||||||
private String parentMenuName;
|
private String parentMenuName;
|
||||||
|
|
||||||
public Long getTableId()
|
public Long getTableId() {
|
||||||
{
|
|
||||||
return tableId;
|
return tableId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTableId(Long tableId)
|
public void setTableId(Long tableId) {
|
||||||
{
|
|
||||||
this.tableId = tableId;
|
this.tableId = tableId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTableName()
|
public String getTableName() {
|
||||||
{
|
|
||||||
return tableName;
|
return tableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTableName(String tableName)
|
public void setTableName(String tableName) {
|
||||||
{
|
|
||||||
this.tableName = tableName;
|
this.tableName = tableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTableComment()
|
public String getTableComment() {
|
||||||
{
|
|
||||||
return tableComment;
|
return tableComment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTableComment(String tableComment)
|
public void setTableComment(String tableComment) {
|
||||||
{
|
|
||||||
this.tableComment = tableComment;
|
this.tableComment = tableComment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSubTableName()
|
public String getClassName() {
|
||||||
{
|
|
||||||
return subTableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubTableName(String subTableName)
|
|
||||||
{
|
|
||||||
this.subTableName = subTableName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSubTableFkName()
|
|
||||||
{
|
|
||||||
return subTableFkName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubTableFkName(String subTableFkName)
|
|
||||||
{
|
|
||||||
this.subTableFkName = subTableFkName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClassName()
|
|
||||||
{
|
|
||||||
return className;
|
return className;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClassName(String className)
|
public void setClassName(String className) {
|
||||||
{
|
|
||||||
this.className = className;
|
this.className = className;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTplCategory()
|
public String getTplCategory() {
|
||||||
{
|
|
||||||
return tplCategory;
|
return tplCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTplCategory(String tplCategory)
|
public void setTplCategory(String tplCategory) {
|
||||||
{
|
|
||||||
this.tplCategory = tplCategory;
|
this.tplCategory = tplCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPackageName()
|
public String getPackageName() {
|
||||||
{
|
|
||||||
return packageName;
|
return packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPackageName(String packageName)
|
public void setPackageName(String packageName) {
|
||||||
{
|
|
||||||
this.packageName = packageName;
|
this.packageName = packageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getModuleName()
|
public String getModuleName() {
|
||||||
{
|
|
||||||
return moduleName;
|
return moduleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModuleName(String moduleName)
|
public void setModuleName(String moduleName) {
|
||||||
{
|
|
||||||
this.moduleName = moduleName;
|
this.moduleName = moduleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBusinessName()
|
public String getBusinessName() {
|
||||||
{
|
|
||||||
return businessName;
|
return businessName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBusinessName(String businessName)
|
public void setBusinessName(String businessName) {
|
||||||
{
|
|
||||||
this.businessName = businessName;
|
this.businessName = businessName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFunctionName()
|
public String getFunctionName() {
|
||||||
{
|
|
||||||
return functionName;
|
return functionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFunctionName(String functionName)
|
public void setFunctionName(String functionName) {
|
||||||
{
|
|
||||||
this.functionName = functionName;
|
this.functionName = functionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFunctionAuthor()
|
public String getFunctionAuthor() {
|
||||||
{
|
|
||||||
return functionAuthor;
|
return functionAuthor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFunctionAuthor(String functionAuthor)
|
public void setFunctionAuthor(String functionAuthor) {
|
||||||
{
|
|
||||||
this.functionAuthor = functionAuthor;
|
this.functionAuthor = functionAuthor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGenType()
|
public String getGenType() {
|
||||||
{
|
|
||||||
return genType;
|
return genType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGenType(String genType)
|
public void setGenType(String genType) {
|
||||||
{
|
|
||||||
this.genType = genType;
|
this.genType = genType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGenPath()
|
public String getGenPath() {
|
||||||
{
|
|
||||||
return genPath;
|
return genPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGenPath(String genPath)
|
public void setGenPath(String genPath) {
|
||||||
{
|
|
||||||
this.genPath = genPath;
|
this.genPath = genPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenTableColumn getPkColumn()
|
public GenTableColumn getPkColumn() {
|
||||||
{
|
|
||||||
return pkColumn;
|
return pkColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPkColumn(GenTableColumn pkColumn)
|
public void setPkColumn(GenTableColumn pkColumn) {
|
||||||
{
|
|
||||||
this.pkColumn = pkColumn;
|
this.pkColumn = pkColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenTable getSubTable()
|
public List<GenTableColumn> getColumns() {
|
||||||
{
|
|
||||||
return subTable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubTable(GenTable subTable)
|
|
||||||
{
|
|
||||||
this.subTable = subTable;
|
|
||||||
}
|
|
||||||
public List<GenTableColumn> getColumns()
|
|
||||||
{
|
|
||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColumns(List<GenTableColumn> columns)
|
public void setColumns(List<GenTableColumn> columns) {
|
||||||
{
|
|
||||||
this.columns = columns;
|
this.columns = columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOptions()
|
public String getOptions() {
|
||||||
{
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOptions(String options)
|
public void setOptions(String options) {
|
||||||
{
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTreeCode()
|
public String getTreeCode() {
|
||||||
{
|
|
||||||
return treeCode;
|
return treeCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTreeCode(String treeCode)
|
public void setTreeCode(String treeCode) {
|
||||||
{
|
|
||||||
this.treeCode = treeCode;
|
this.treeCode = treeCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTreeParentCode()
|
public String getTreeParentCode() {
|
||||||
{
|
|
||||||
return treeParentCode;
|
return treeParentCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTreeParentCode(String treeParentCode)
|
public void setTreeParentCode(String treeParentCode) {
|
||||||
{
|
|
||||||
this.treeParentCode = treeParentCode;
|
this.treeParentCode = treeParentCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTreeName()
|
public String getTreeName() {
|
||||||
{
|
|
||||||
return treeName;
|
return treeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTreeName(String treeName)
|
public void setTreeName(String treeName) {
|
||||||
{
|
|
||||||
this.treeName = treeName;
|
this.treeName = treeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getParentMenuId()
|
public String getParentMenuId() {
|
||||||
{
|
|
||||||
return parentMenuId;
|
return parentMenuId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentMenuId(String parentMenuId)
|
public void setParentMenuId(String parentMenuId) {
|
||||||
{
|
|
||||||
this.parentMenuId = parentMenuId;
|
this.parentMenuId = parentMenuId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getParentMenuName()
|
public String getParentMenuName() {
|
||||||
{
|
|
||||||
return parentMenuName;
|
return parentMenuName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentMenuName(String parentMenuName)
|
public void setParentMenuName(String parentMenuName) {
|
||||||
{
|
|
||||||
this.parentMenuName = parentMenuName;
|
this.parentMenuName = parentMenuName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSub()
|
public boolean isTree() {
|
||||||
{
|
return isTree(tplCategory);
|
||||||
return isSub(this.tplCategory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSub(String tplCategory)
|
public static boolean isTree(String tplCategory) {
|
||||||
{
|
|
||||||
return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory);
|
|
||||||
}
|
|
||||||
public boolean isTree()
|
|
||||||
{
|
|
||||||
return isTree(this.tplCategory);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isTree(String tplCategory)
|
|
||||||
{
|
|
||||||
return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory);
|
return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCrud()
|
public boolean isCrud() {
|
||||||
{
|
return isCrud(tplCategory);
|
||||||
return isCrud(this.tplCategory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isCrud(String tplCategory)
|
public static boolean isCrud(String tplCategory) {
|
||||||
{
|
|
||||||
return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory);
|
return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSuperColumn(String javaField)
|
public boolean isSuperColumn(String javaField) {
|
||||||
{
|
return isSuperColumn(tplCategory, javaField);
|
||||||
return isSuperColumn(this.tplCategory, javaField);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSuperColumn(String tplCategory, String javaField)
|
public static boolean isSuperColumn(String tplCategory, String javaField) {
|
||||||
{
|
if (isTree(tplCategory)) {
|
||||||
if (isTree(tplCategory))
|
|
||||||
{
|
|
||||||
return StringUtils.equalsAnyIgnoreCase(javaField,
|
return StringUtils.equalsAnyIgnoreCase(javaField,
|
||||||
ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY));
|
ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,336 +1,314 @@
|
||||||
package com.ruoyi.gen.domain;
|
package com.ruoyi.gen.domain;
|
||||||
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
|
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码生成业务字段表 gen_table_column
|
* 代码生成业务字段表 gen_table_column
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class GenTableColumn extends BaseEntity
|
public class GenTableColumn extends BaseEntity {
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 编号 */
|
/**
|
||||||
|
* 编号
|
||||||
|
*/
|
||||||
private Long columnId;
|
private Long columnId;
|
||||||
|
|
||||||
/** 归属表编号 */
|
/**
|
||||||
|
* 归属表编号
|
||||||
|
*/
|
||||||
private Long tableId;
|
private Long tableId;
|
||||||
|
|
||||||
/** 列名称 */
|
/**
|
||||||
|
* 列名称
|
||||||
|
*/
|
||||||
private String columnName;
|
private String columnName;
|
||||||
|
|
||||||
/** 列描述 */
|
/**
|
||||||
|
* 列描述
|
||||||
|
*/
|
||||||
private String columnComment;
|
private String columnComment;
|
||||||
|
|
||||||
/** 列类型 */
|
/**
|
||||||
|
* 列类型
|
||||||
|
*/
|
||||||
private String columnType;
|
private String columnType;
|
||||||
|
|
||||||
/** JAVA类型 */
|
/**
|
||||||
|
* JAVA类型
|
||||||
|
*/
|
||||||
private String javaType;
|
private String javaType;
|
||||||
|
|
||||||
/** JAVA字段名 */
|
/**
|
||||||
|
* JAVA字段名
|
||||||
|
*/
|
||||||
@NotBlank(message = "Java属性不能为空")
|
@NotBlank(message = "Java属性不能为空")
|
||||||
private String javaField;
|
private String javaField;
|
||||||
|
|
||||||
/** 是否主键(1是) */
|
/**
|
||||||
|
* 是否主键(1是)
|
||||||
|
*/
|
||||||
private String isPk;
|
private String isPk;
|
||||||
|
|
||||||
/** 是否自增(1是) */
|
/**
|
||||||
|
* 是否自增(1是)
|
||||||
|
*/
|
||||||
private String isIncrement;
|
private String isIncrement;
|
||||||
|
|
||||||
/** 是否必填(1是) */
|
/**
|
||||||
|
* 是否必填(1是)
|
||||||
|
*/
|
||||||
private String isRequired;
|
private String isRequired;
|
||||||
|
|
||||||
/** 是否为插入字段(1是) */
|
/**
|
||||||
|
* 是否为插入字段(1是)
|
||||||
|
*/
|
||||||
private String isInsert;
|
private String isInsert;
|
||||||
|
|
||||||
/** 是否编辑字段(1是) */
|
/**
|
||||||
|
* 是否编辑字段(1是)
|
||||||
|
*/
|
||||||
private String isEdit;
|
private String isEdit;
|
||||||
|
|
||||||
/** 是否列表字段(1是) */
|
/**
|
||||||
|
* 是否列表字段(1是)
|
||||||
|
*/
|
||||||
private String isList;
|
private String isList;
|
||||||
|
|
||||||
/** 是否查询字段(1是) */
|
/**
|
||||||
|
* 是否查询字段(1是)
|
||||||
|
*/
|
||||||
private String isQuery;
|
private String isQuery;
|
||||||
|
|
||||||
/** 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围) */
|
/**
|
||||||
|
* 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围)
|
||||||
|
*/
|
||||||
private String queryType;
|
private String queryType;
|
||||||
|
|
||||||
/** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件) */
|
/**
|
||||||
|
* 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、upload上传控件、editor富文本控件)
|
||||||
|
*/
|
||||||
private String htmlType;
|
private String htmlType;
|
||||||
|
|
||||||
/** 字典类型 */
|
/**
|
||||||
|
* 字典类型
|
||||||
|
*/
|
||||||
private String dictType;
|
private String dictType;
|
||||||
|
|
||||||
/** 排序 */
|
/**
|
||||||
|
* 排序
|
||||||
|
*/
|
||||||
private Integer sort;
|
private Integer sort;
|
||||||
|
|
||||||
public void setColumnId(Long columnId)
|
public void setColumnId(Long columnId) {
|
||||||
{
|
|
||||||
this.columnId = columnId;
|
this.columnId = columnId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getColumnId()
|
public Long getColumnId() {
|
||||||
{
|
|
||||||
return columnId;
|
return columnId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTableId(Long tableId)
|
public void setTableId(Long tableId) {
|
||||||
{
|
|
||||||
this.tableId = tableId;
|
this.tableId = tableId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getTableId()
|
public Long getTableId() {
|
||||||
{
|
|
||||||
return tableId;
|
return tableId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColumnName(String columnName)
|
public void setColumnName(String columnName) {
|
||||||
{
|
|
||||||
this.columnName = columnName;
|
this.columnName = columnName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColumnName()
|
public String getColumnName() {
|
||||||
{
|
|
||||||
return columnName;
|
return columnName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColumnComment(String columnComment)
|
public void setColumnComment(String columnComment) {
|
||||||
{
|
|
||||||
this.columnComment = columnComment;
|
this.columnComment = columnComment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColumnComment()
|
public String getColumnComment() {
|
||||||
{
|
|
||||||
return columnComment;
|
return columnComment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColumnType(String columnType)
|
public void setColumnType(String columnType) {
|
||||||
{
|
|
||||||
this.columnType = columnType;
|
this.columnType = columnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColumnType()
|
public String getColumnType() {
|
||||||
{
|
|
||||||
return columnType;
|
return columnType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJavaType(String javaType)
|
public void setJavaType(String javaType) {
|
||||||
{
|
|
||||||
this.javaType = javaType;
|
this.javaType = javaType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getJavaType()
|
public String getJavaType() {
|
||||||
{
|
|
||||||
return javaType;
|
return javaType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJavaField(String javaField)
|
public void setJavaField(String javaField) {
|
||||||
{
|
|
||||||
this.javaField = javaField;
|
this.javaField = javaField;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getJavaField()
|
public String getJavaField() {
|
||||||
{
|
|
||||||
return javaField;
|
return javaField;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCapJavaField()
|
public void setIsPk(String isPk) {
|
||||||
{
|
|
||||||
return StringUtils.capitalize(javaField);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsPk(String isPk)
|
|
||||||
{
|
|
||||||
this.isPk = isPk;
|
this.isPk = isPk;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIsPk()
|
public String getIsPk() {
|
||||||
{
|
|
||||||
return isPk;
|
return isPk;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPk()
|
public boolean isPk() {
|
||||||
{
|
return isPk(isPk);
|
||||||
return isPk(this.isPk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPk(String isPk)
|
public boolean isPk(String isPk) {
|
||||||
{
|
|
||||||
return isPk != null && StringUtils.equals("1", isPk);
|
return isPk != null && StringUtils.equals("1", isPk);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIsIncrement()
|
public String getIsIncrement() {
|
||||||
{
|
|
||||||
return isIncrement;
|
return isIncrement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsIncrement(String isIncrement)
|
public void setIsIncrement(String isIncrement) {
|
||||||
{
|
|
||||||
this.isIncrement = isIncrement;
|
this.isIncrement = isIncrement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIncrement()
|
public boolean isIncrement() {
|
||||||
{
|
return isIncrement(isIncrement);
|
||||||
return isIncrement(this.isIncrement);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIncrement(String isIncrement)
|
public boolean isIncrement(String isIncrement) {
|
||||||
{
|
|
||||||
return isIncrement != null && StringUtils.equals("1", isIncrement);
|
return isIncrement != null && StringUtils.equals("1", isIncrement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsRequired(String isRequired)
|
public void setIsRequired(String isRequired) {
|
||||||
{
|
|
||||||
this.isRequired = isRequired;
|
this.isRequired = isRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIsRequired()
|
public String getIsRequired() {
|
||||||
{
|
|
||||||
return isRequired;
|
return isRequired;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRequired()
|
public boolean isRequired() {
|
||||||
{
|
return isRequired(isRequired);
|
||||||
return isRequired(this.isRequired);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRequired(String isRequired)
|
public boolean isRequired(String isRequired) {
|
||||||
{
|
|
||||||
return isRequired != null && StringUtils.equals("1", isRequired);
|
return isRequired != null && StringUtils.equals("1", isRequired);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsInsert(String isInsert)
|
public void setIsInsert(String isInsert) {
|
||||||
{
|
|
||||||
this.isInsert = isInsert;
|
this.isInsert = isInsert;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIsInsert()
|
public String getIsInsert() {
|
||||||
{
|
|
||||||
return isInsert;
|
return isInsert;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInsert()
|
public boolean isInsert() {
|
||||||
{
|
return isInsert(isInsert);
|
||||||
return isInsert(this.isInsert);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInsert(String isInsert)
|
public boolean isInsert(String isInsert) {
|
||||||
{
|
|
||||||
return isInsert != null && StringUtils.equals("1", isInsert);
|
return isInsert != null && StringUtils.equals("1", isInsert);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsEdit(String isEdit)
|
public void setIsEdit(String isEdit) {
|
||||||
{
|
|
||||||
this.isEdit = isEdit;
|
this.isEdit = isEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIsEdit()
|
public String getIsEdit() {
|
||||||
{
|
|
||||||
return isEdit;
|
return isEdit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEdit()
|
public boolean isEdit() {
|
||||||
{
|
return isInsert(isEdit);
|
||||||
return isInsert(this.isEdit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEdit(String isEdit)
|
public boolean isEdit(String isEdit) {
|
||||||
{
|
|
||||||
return isEdit != null && StringUtils.equals("1", isEdit);
|
return isEdit != null && StringUtils.equals("1", isEdit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsList(String isList)
|
public void setIsList(String isList) {
|
||||||
{
|
|
||||||
this.isList = isList;
|
this.isList = isList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIsList()
|
public String getIsList() {
|
||||||
{
|
|
||||||
return isList;
|
return isList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isList()
|
public boolean isList() {
|
||||||
{
|
return isList(isList);
|
||||||
return isList(this.isList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isList(String isList)
|
public boolean isList(String isList) {
|
||||||
{
|
|
||||||
return isList != null && StringUtils.equals("1", isList);
|
return isList != null && StringUtils.equals("1", isList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsQuery(String isQuery)
|
public void setIsQuery(String isQuery) {
|
||||||
{
|
|
||||||
this.isQuery = isQuery;
|
this.isQuery = isQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getIsQuery()
|
public String getIsQuery() {
|
||||||
{
|
|
||||||
return isQuery;
|
return isQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isQuery()
|
public boolean isQuery() {
|
||||||
{
|
return isQuery(isQuery);
|
||||||
return isQuery(this.isQuery);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isQuery(String isQuery)
|
public boolean isQuery(String isQuery) {
|
||||||
{
|
|
||||||
return isQuery != null && StringUtils.equals("1", isQuery);
|
return isQuery != null && StringUtils.equals("1", isQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setQueryType(String queryType)
|
public void setQueryType(String queryType) {
|
||||||
{
|
|
||||||
this.queryType = queryType;
|
this.queryType = queryType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getQueryType()
|
public String getQueryType() {
|
||||||
{
|
|
||||||
return queryType;
|
return queryType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHtmlType()
|
public String getHtmlType() {
|
||||||
{
|
|
||||||
return htmlType;
|
return htmlType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHtmlType(String htmlType)
|
public void setHtmlType(String htmlType) {
|
||||||
{
|
|
||||||
this.htmlType = htmlType;
|
this.htmlType = htmlType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDictType(String dictType)
|
public void setDictType(String dictType) {
|
||||||
{
|
|
||||||
this.dictType = dictType;
|
this.dictType = dictType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDictType()
|
public String getDictType() {
|
||||||
{
|
|
||||||
return dictType;
|
return dictType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSort(Integer sort)
|
public void setSort(Integer sort) {
|
||||||
{
|
|
||||||
this.sort = sort;
|
this.sort = sort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getSort()
|
public Integer getSort() {
|
||||||
{
|
|
||||||
return sort;
|
return sort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSuperColumn()
|
public boolean isSuperColumn() {
|
||||||
{
|
return isSuperColumn(javaField);
|
||||||
return isSuperColumn(this.javaField);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSuperColumn(String javaField)
|
public static boolean isSuperColumn(String javaField) {
|
||||||
{
|
|
||||||
return StringUtils.equalsAnyIgnoreCase(javaField,
|
return StringUtils.equalsAnyIgnoreCase(javaField,
|
||||||
// BaseEntity
|
// BaseEntity
|
||||||
"createBy", "createTime", "updateBy", "updateTime", "remark",
|
"createBy", "createTime", "updateBy", "updateTime", "remark",
|
||||||
|
|
@ -338,37 +316,29 @@ public class GenTableColumn extends BaseEntity
|
||||||
"parentName", "parentId", "orderNum", "ancestors");
|
"parentName", "parentId", "orderNum", "ancestors");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUsableColumn()
|
public boolean isUsableColumn() {
|
||||||
{
|
|
||||||
return isUsableColumn(javaField);
|
return isUsableColumn(javaField);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUsableColumn(String javaField)
|
public static boolean isUsableColumn(String javaField) {
|
||||||
{
|
|
||||||
// isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单
|
// isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单
|
||||||
return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark");
|
return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String readConverterExp()
|
public String readConverterExp() {
|
||||||
{
|
String remarks = StringUtils.substringBetween(columnComment, "(", ")");
|
||||||
String remarks = StringUtils.substringBetween(this.columnComment, "(", ")");
|
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
if (StringUtils.isNotEmpty(remarks))
|
if (StringUtils.isNotEmpty(remarks)) {
|
||||||
{
|
for (String value : remarks.split(" ")) {
|
||||||
for (String value : remarks.split(" "))
|
if (StringUtils.isNotEmpty(value)) {
|
||||||
{
|
|
||||||
if (StringUtils.isNotEmpty(value))
|
|
||||||
{
|
|
||||||
Object startStr = value.subSequence(0, 1);
|
Object startStr = value.subSequence(0, 1);
|
||||||
String endStr = value.substring(1);
|
String endStr = value.substring(1);
|
||||||
sb.append("").append(startStr).append("=").append(endStr).append(",");
|
sb.append("").append(startStr).append("=").append(endStr).append(",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sb.deleteCharAt(sb.length() - 1).toString();
|
return sb.deleteCharAt(sb.length() - 1).toString();
|
||||||
}
|
} else {
|
||||||
else
|
return columnComment;
|
||||||
{
|
|
||||||
return this.columnComment;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
package com.ruoyi.gen.mapper;
|
package com.ruoyi.gen.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import com.ruoyi.gen.domain.GenTableColumn;
|
import com.ruoyi.gen.domain.GenTableColumn;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务字段 数据层
|
* 业务字段 数据层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public interface GenTableColumnMapper
|
public interface GenTableColumnMapper {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 根据表名称查询列信息
|
* 根据表名称查询列信息
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
package com.ruoyi.gen.mapper;
|
package com.ruoyi.gen.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import com.ruoyi.gen.domain.GenTable;
|
import com.ruoyi.gen.domain.GenTable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务 数据层
|
* 业务 数据层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public interface GenTableMapper
|
public interface GenTableMapper {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 查询业务列表
|
* 查询业务列表
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
package com.ruoyi.gen.service;
|
package com.ruoyi.gen.service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import com.ruoyi.common.core.text.Convert;
|
import com.ruoyi.common.core.text.Convert;
|
||||||
import com.ruoyi.gen.domain.GenTableColumn;
|
import com.ruoyi.gen.domain.GenTableColumn;
|
||||||
import com.ruoyi.gen.mapper.GenTableColumnMapper;
|
import com.ruoyi.gen.mapper.GenTableColumnMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务字段 服务层实现
|
* 业务字段 服务层实现
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service("genTableColumnService")
|
||||||
public class GenTableColumnServiceImpl implements IGenTableColumnService
|
public class GenTableColumnServiceImpl implements IGenTableColumnService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private GenTableColumnMapper genTableColumnMapper;
|
private GenTableColumnMapper genTableColumnMapper;
|
||||||
|
|
||||||
|
|
@ -25,8 +25,7 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService
|
||||||
* @return 业务字段集合
|
* @return 业务字段集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId)
|
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) {
|
||||||
{
|
|
||||||
return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
|
return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,8 +36,7 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertGenTableColumn(GenTableColumn genTableColumn)
|
public int insertGenTableColumn(GenTableColumn genTableColumn) {
|
||||||
{
|
|
||||||
return genTableColumnMapper.insertGenTableColumn(genTableColumn);
|
return genTableColumnMapper.insertGenTableColumn(genTableColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,8 +47,7 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateGenTableColumn(GenTableColumn genTableColumn)
|
public int updateGenTableColumn(GenTableColumn genTableColumn) {
|
||||||
{
|
|
||||||
return genTableColumnMapper.updateGenTableColumn(genTableColumn);
|
return genTableColumnMapper.updateGenTableColumn(genTableColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,8 +58,7 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteGenTableColumnByIds(String ids)
|
public int deleteGenTableColumnByIds(String ids) {
|
||||||
{
|
|
||||||
return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
|
return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,24 +1,5 @@
|
||||||
package com.ruoyi.gen.service;
|
package com.ruoyi.gen.service;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
import java.util.zip.ZipOutputStream;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.apache.velocity.Template;
|
|
||||||
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 org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
|
|
@ -35,6 +16,26 @@ import com.ruoyi.gen.mapper.GenTableMapper;
|
||||||
import com.ruoyi.gen.util.GenUtils;
|
import com.ruoyi.gen.util.GenUtils;
|
||||||
import com.ruoyi.gen.util.VelocityInitializer;
|
import com.ruoyi.gen.util.VelocityInitializer;
|
||||||
import com.ruoyi.gen.util.VelocityUtils;
|
import com.ruoyi.gen.util.VelocityUtils;
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.velocity.Template;
|
||||||
|
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 org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务 服务层实现
|
* 业务 服务层实现
|
||||||
|
|
@ -42,8 +43,7 @@ import com.ruoyi.gen.util.VelocityUtils;
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class GenTableServiceImpl implements IGenTableService
|
public class GenTableServiceImpl implements IGenTableService {
|
||||||
{
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -59,8 +59,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* @return 业务信息
|
* @return 业务信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public GenTable selectGenTableById(Long id)
|
public GenTable selectGenTableById(Long id) {
|
||||||
{
|
|
||||||
GenTable genTable = genTableMapper.selectGenTableById(id);
|
GenTable genTable = genTableMapper.selectGenTableById(id);
|
||||||
setTableFromOptions(genTable);
|
setTableFromOptions(genTable);
|
||||||
return genTable;
|
return genTable;
|
||||||
|
|
@ -73,8 +72,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* @return 业务集合
|
* @return 业务集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<GenTable> selectGenTableList(GenTable genTable)
|
public List<GenTable> selectGenTableList(GenTable genTable) {
|
||||||
{
|
|
||||||
return genTableMapper.selectGenTableList(genTable);
|
return genTableMapper.selectGenTableList(genTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,8 +83,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* @return 数据库表集合
|
* @return 数据库表集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<GenTable> selectDbTableList(GenTable genTable)
|
public List<GenTable> selectDbTableList(GenTable genTable) {
|
||||||
{
|
|
||||||
return genTableMapper.selectDbTableList(genTable);
|
return genTableMapper.selectDbTableList(genTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -97,22 +94,10 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* @return 数据库表集合
|
* @return 数据库表集合
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<GenTable> selectDbTableListByNames(String[] tableNames)
|
public List<GenTable> selectDbTableListByNames(String[] tableNames) {
|
||||||
{
|
|
||||||
return genTableMapper.selectDbTableListByNames(tableNames);
|
return genTableMapper.selectDbTableListByNames(tableNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询所有表信息
|
|
||||||
*
|
|
||||||
* @return 表信息集合
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public List<GenTable> selectGenTableAll()
|
|
||||||
{
|
|
||||||
return genTableMapper.selectGenTableAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改业务
|
* 修改业务
|
||||||
*
|
*
|
||||||
|
|
@ -121,15 +106,12 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void updateGenTable(GenTable genTable)
|
public void updateGenTable(GenTable genTable) {
|
||||||
{
|
|
||||||
String options = JSON.toJSONString(genTable.getParams());
|
String options = JSON.toJSONString(genTable.getParams());
|
||||||
genTable.setOptions(options);
|
genTable.setOptions(options);
|
||||||
int row = genTableMapper.updateGenTable(genTable);
|
int row = genTableMapper.updateGenTable(genTable);
|
||||||
if (row > 0)
|
if (row > 0) {
|
||||||
{
|
for (GenTableColumn cenTableColumn : genTable.getColumns()) {
|
||||||
for (GenTableColumn cenTableColumn : genTable.getColumns())
|
|
||||||
{
|
|
||||||
genTableColumnMapper.updateGenTableColumn(cenTableColumn);
|
genTableColumnMapper.updateGenTableColumn(cenTableColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -143,8 +125,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void deleteGenTableByIds(Long[] tableIds)
|
public void deleteGenTableByIds(Long[] tableIds) {
|
||||||
{
|
|
||||||
genTableMapper.deleteGenTableByIds(tableIds);
|
genTableMapper.deleteGenTableByIds(tableIds);
|
||||||
genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
|
genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
|
||||||
}
|
}
|
||||||
|
|
@ -156,30 +137,23 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void importGenTable(List<GenTable> tableList)
|
public void importGenTable(List<GenTable> tableList) {
|
||||||
{
|
|
||||||
String operName = SecurityUtils.getUsername();
|
String operName = SecurityUtils.getUsername();
|
||||||
try
|
try {
|
||||||
{
|
for (GenTable table : tableList) {
|
||||||
for (GenTable table : tableList)
|
|
||||||
{
|
|
||||||
String tableName = table.getTableName();
|
String tableName = table.getTableName();
|
||||||
GenUtils.initTable(table, operName);
|
GenUtils.initTable(table, operName);
|
||||||
int row = genTableMapper.insertGenTable(table);
|
int row = genTableMapper.insertGenTable(table);
|
||||||
if (row > 0)
|
if (row > 0) {
|
||||||
{
|
|
||||||
// 保存列信息
|
// 保存列信息
|
||||||
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
||||||
for (GenTableColumn column : genTableColumns)
|
for (GenTableColumn column : genTableColumns) {
|
||||||
{
|
|
||||||
GenUtils.initColumnField(column, table);
|
GenUtils.initColumnField(column, table);
|
||||||
genTableColumnMapper.insertGenTableColumn(column);
|
genTableColumnMapper.insertGenTableColumn(column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new CustomException("导入失败:" + e.getMessage());
|
throw new CustomException("导入失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -191,23 +165,20 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* @return 预览数据列表
|
* @return 预览数据列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> previewCode(Long tableId)
|
public Map<String, String> previewCode(Long tableId) {
|
||||||
{
|
|
||||||
Map<String, String> dataMap = new LinkedHashMap<>();
|
Map<String, String> dataMap = new LinkedHashMap<>();
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
GenTable table = genTableMapper.selectGenTableById(tableId);
|
GenTable table = genTableMapper.selectGenTableById(tableId);
|
||||||
// 设置主子表信息
|
// 查询列信息
|
||||||
setSubTable(table);
|
List<GenTableColumn> columns = table.getColumns();
|
||||||
// 设置主键列信息
|
setPkColumn(table, columns);
|
||||||
setPkColumn(table);
|
|
||||||
VelocityInitializer.initVelocity();
|
VelocityInitializer.initVelocity();
|
||||||
|
|
||||||
VelocityContext context = VelocityUtils.prepareContext(table);
|
VelocityContext context = VelocityUtils.prepareContext(table);
|
||||||
|
|
||||||
// 获取模板列表
|
// 获取模板列表
|
||||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||||
for (String template : templates)
|
for (String template : templates) {
|
||||||
{
|
|
||||||
// 渲染模板
|
// 渲染模板
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
||||||
|
|
@ -224,8 +195,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* @return 数据
|
* @return 数据
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public byte[] downloadCode(String tableName)
|
public byte[] downloadCode(String tableName) {
|
||||||
{
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
||||||
generatorCode(tableName, zip);
|
generatorCode(tableName, zip);
|
||||||
|
|
@ -239,14 +209,12 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void generatorCode(String tableName)
|
public void generatorCode(String tableName) {
|
||||||
{
|
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
||||||
// 设置主子表信息
|
// 查询列信息
|
||||||
setSubTable(table);
|
List<GenTableColumn> columns = table.getColumns();
|
||||||
// 设置主键列信息
|
setPkColumn(table, columns);
|
||||||
setPkColumn(table);
|
|
||||||
|
|
||||||
VelocityInitializer.initVelocity();
|
VelocityInitializer.initVelocity();
|
||||||
|
|
||||||
|
|
@ -254,21 +222,16 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
|
|
||||||
// 获取模板列表
|
// 获取模板列表
|
||||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||||
for (String template : templates)
|
for (String template : templates) {
|
||||||
{
|
if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) {
|
||||||
if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm"))
|
|
||||||
{
|
|
||||||
// 渲染模板
|
// 渲染模板
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
||||||
tpl.merge(context, sw);
|
tpl.merge(context, sw);
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
String path = getGenPath(table, template);
|
String path = getGenPath(table, template);
|
||||||
FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8);
|
FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8);
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
throw new CustomException("渲染模板失败,表名:" + table.getTableName());
|
throw new CustomException("渲染模板失败,表名:" + table.getTableName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -282,30 +245,23 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void synchDb(String tableName)
|
public void synchDb(String tableName) {
|
||||||
{
|
|
||||||
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
||||||
List<GenTableColumn> tableColumns = table.getColumns();
|
List<GenTableColumn> tableColumns = table.getColumns();
|
||||||
List<String> tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
List<String> tableColumnNames = tableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
||||||
|
|
||||||
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
|
||||||
if (StringUtils.isEmpty(dbTableColumns))
|
|
||||||
{
|
|
||||||
throw new CustomException("同步数据失败,原表结构不存在");
|
|
||||||
}
|
|
||||||
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
|
||||||
|
|
||||||
dbTableColumns.forEach(column -> {
|
dbTableColumns.forEach(column -> {
|
||||||
if (!tableColumnNames.contains(column.getColumnName()))
|
if (!tableColumnNames.contains(column.getColumnName())) {
|
||||||
{
|
|
||||||
GenUtils.initColumnField(column, table);
|
GenUtils.initColumnField(column, table);
|
||||||
genTableColumnMapper.insertGenTableColumn(column);
|
genTableColumnMapper.insertGenTableColumn(column);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
|
List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
|
||||||
if (StringUtils.isNotEmpty(delColumns))
|
if (StringUtils.isNotEmpty(delColumns)) {
|
||||||
{
|
|
||||||
genTableColumnMapper.deleteGenTableColumns(delColumns);
|
genTableColumnMapper.deleteGenTableColumns(delColumns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -317,12 +273,10 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* @return 数据
|
* @return 数据
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public byte[] downloadCode(String[] tableNames)
|
public byte[] downloadCode(String[] tableNames) {
|
||||||
{
|
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
ZipOutputStream zip = new ZipOutputStream(outputStream);
|
||||||
for (String tableName : tableNames)
|
for (String tableName : tableNames) {
|
||||||
{
|
|
||||||
generatorCode(tableName, zip);
|
generatorCode(tableName, zip);
|
||||||
}
|
}
|
||||||
IOUtils.closeQuietly(zip);
|
IOUtils.closeQuietly(zip);
|
||||||
|
|
@ -332,14 +286,12 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
/**
|
/**
|
||||||
* 查询表信息并生成代码
|
* 查询表信息并生成代码
|
||||||
*/
|
*/
|
||||||
private void generatorCode(String tableName, ZipOutputStream zip)
|
private void generatorCode(String tableName, ZipOutputStream zip) {
|
||||||
{
|
|
||||||
// 查询表信息
|
// 查询表信息
|
||||||
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
GenTable table = genTableMapper.selectGenTableByName(tableName);
|
||||||
// 设置主子表信息
|
// 查询列信息
|
||||||
setSubTable(table);
|
List<GenTableColumn> columns = table.getColumns();
|
||||||
// 设置主键列信息
|
setPkColumn(table, columns);
|
||||||
setPkColumn(table);
|
|
||||||
|
|
||||||
VelocityInitializer.initVelocity();
|
VelocityInitializer.initVelocity();
|
||||||
|
|
||||||
|
|
@ -347,23 +299,19 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
|
|
||||||
// 获取模板列表
|
// 获取模板列表
|
||||||
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
|
||||||
for (String template : templates)
|
for (String template : templates) {
|
||||||
{
|
|
||||||
// 渲染模板
|
// 渲染模板
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
Template tpl = Velocity.getTemplate(template, Constants.UTF8);
|
||||||
tpl.merge(context, sw);
|
tpl.merge(context, sw);
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
// 添加到zip
|
// 添加到zip
|
||||||
zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
|
zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
|
||||||
IOUtils.write(sw.toString(), zip, Constants.UTF8);
|
IOUtils.write(sw.toString(), zip, Constants.UTF8);
|
||||||
IOUtils.closeQuietly(sw);
|
IOUtils.closeQuietly(sw);
|
||||||
zip.flush();
|
zip.flush();
|
||||||
zip.closeEntry();
|
zip.closeEntry();
|
||||||
}
|
} catch (IOException e) {
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
log.error("渲染模板失败,表名:" + table.getTableName(), e);
|
log.error("渲染模板失败,表名:" + table.getTableName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -375,35 +323,17 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* @param genTable 业务信息
|
* @param genTable 业务信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void validateEdit(GenTable genTable)
|
public void validateEdit(GenTable genTable) {
|
||||||
{
|
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
|
||||||
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory()))
|
|
||||||
{
|
|
||||||
String options = JSON.toJSONString(genTable.getParams());
|
String options = JSON.toJSONString(genTable.getParams());
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
JSONObject paramsObj = JSONObject.parseObject(options);
|
||||||
if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE)))
|
if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) {
|
||||||
{
|
|
||||||
throw new CustomException("树编码字段不能为空");
|
throw new CustomException("树编码字段不能为空");
|
||||||
}
|
} else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) {
|
||||||
else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE)))
|
|
||||||
{
|
|
||||||
throw new CustomException("树父编码字段不能为空");
|
throw new CustomException("树父编码字段不能为空");
|
||||||
}
|
} else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) {
|
||||||
else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME)))
|
|
||||||
{
|
|
||||||
throw new CustomException("树名称字段不能为空");
|
throw new CustomException("树名称字段不能为空");
|
||||||
}
|
}
|
||||||
else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory()))
|
|
||||||
{
|
|
||||||
if (StringUtils.isEmpty(genTable.getSubTableName()))
|
|
||||||
{
|
|
||||||
throw new CustomException("关联子表的表名不能为空");
|
|
||||||
}
|
|
||||||
else if (StringUtils.isEmpty(genTable.getSubTableFkName()))
|
|
||||||
{
|
|
||||||
throw new CustomException("子表关联的外键名不能为空");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -411,48 +341,17 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* 设置主键列信息
|
* 设置主键列信息
|
||||||
*
|
*
|
||||||
* @param table 业务表信息
|
* @param table 业务表信息
|
||||||
|
* @param columns 业务字段列表
|
||||||
*/
|
*/
|
||||||
public void setPkColumn(GenTable table)
|
public void setPkColumn(GenTable table, List<GenTableColumn> columns) {
|
||||||
{
|
for (GenTableColumn column : columns) {
|
||||||
for (GenTableColumn column : table.getColumns())
|
if (column.isPk()) {
|
||||||
{
|
|
||||||
if (column.isPk())
|
|
||||||
{
|
|
||||||
table.setPkColumn(column);
|
table.setPkColumn(column);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (StringUtils.isNull(table.getPkColumn()))
|
if (StringUtils.isNull(table.getPkColumn())) {
|
||||||
{
|
table.setPkColumn(columns.get(0));
|
||||||
table.setPkColumn(table.getColumns().get(0));
|
|
||||||
}
|
|
||||||
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()))
|
|
||||||
{
|
|
||||||
table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 设置主子表信息
|
|
||||||
*
|
|
||||||
* @param table 业务表信息
|
|
||||||
*/
|
|
||||||
public void setSubTable(GenTable table)
|
|
||||||
{
|
|
||||||
String subTableName = table.getSubTableName();
|
|
||||||
if (StringUtils.isNotEmpty(subTableName))
|
|
||||||
{
|
|
||||||
table.setSubTable(genTableMapper.selectGenTableByName(subTableName));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -461,11 +360,9 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
*
|
*
|
||||||
* @param genTable 设置后的生成对象
|
* @param genTable 设置后的生成对象
|
||||||
*/
|
*/
|
||||||
public void setTableFromOptions(GenTable genTable)
|
public void setTableFromOptions(GenTable genTable) {
|
||||||
{
|
|
||||||
JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions());
|
JSONObject paramsObj = JSONObject.parseObject(genTable.getOptions());
|
||||||
if (StringUtils.isNotNull(paramsObj))
|
if (StringUtils.isNotNull(paramsObj)) {
|
||||||
{
|
|
||||||
String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
|
String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
|
||||||
String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
|
String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
|
||||||
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
||||||
|
|
@ -487,11 +384,9 @@ public class GenTableServiceImpl implements IGenTableService
|
||||||
* @param template 模板文件路径
|
* @param template 模板文件路径
|
||||||
* @return 生成地址
|
* @return 生成地址
|
||||||
*/
|
*/
|
||||||
public static String getGenPath(GenTable table, String template)
|
public static String getGenPath(GenTable table, String template) {
|
||||||
{
|
|
||||||
String genPath = table.getGenPath();
|
String genPath = table.getGenPath();
|
||||||
if (StringUtils.equals(genPath, "/"))
|
if (StringUtils.equals(genPath, "/")) {
|
||||||
{
|
|
||||||
return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table);
|
return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table);
|
||||||
}
|
}
|
||||||
return genPath + File.separator + VelocityUtils.getFileName(template, table);
|
return genPath + File.separator + VelocityUtils.getFileName(template, table);
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
package com.ruoyi.gen.service;
|
package com.ruoyi.gen.service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import com.ruoyi.gen.domain.GenTableColumn;
|
import com.ruoyi.gen.domain.GenTableColumn;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务字段 服务层
|
* 业务字段 服务层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public interface IGenTableColumnService
|
public interface IGenTableColumnService {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 查询业务字段列表
|
* 查询业务字段列表
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,16 @@
|
||||||
package com.ruoyi.gen.service;
|
package com.ruoyi.gen.service;
|
||||||
|
|
||||||
|
import com.ruoyi.gen.domain.GenTable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import com.ruoyi.gen.domain.GenTable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务 服务层
|
* 业务 服务层
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public interface IGenTableService
|
public interface IGenTableService {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 查询业务列表
|
* 查询业务列表
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,24 @@
|
||||||
package com.ruoyi.gen.util;
|
package com.ruoyi.gen.util;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import org.apache.commons.lang3.RegExUtils;
|
|
||||||
import com.ruoyi.common.core.constant.GenConstants;
|
import com.ruoyi.common.core.constant.GenConstants;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.gen.config.GenConfig;
|
import com.ruoyi.gen.config.GenConfig;
|
||||||
import com.ruoyi.gen.domain.GenTable;
|
import com.ruoyi.gen.domain.GenTable;
|
||||||
import com.ruoyi.gen.domain.GenTableColumn;
|
import com.ruoyi.gen.domain.GenTableColumn;
|
||||||
|
import org.apache.commons.lang3.RegExUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码生成器 工具类
|
* 代码生成器 工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class GenUtils
|
public class GenUtils {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 初始化表信息
|
* 初始化表信息
|
||||||
*/
|
*/
|
||||||
public static void initTable(GenTable genTable, String operName)
|
public static void initTable(GenTable genTable, String operName) {
|
||||||
{
|
|
||||||
genTable.setClassName(convertClassName(genTable.getTableName()));
|
genTable.setClassName(convertClassName(genTable.getTableName()));
|
||||||
genTable.setPackageName(GenConfig.getPackageName());
|
genTable.setPackageName(GenConfig.getPackageName());
|
||||||
genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
|
genTable.setModuleName(getModuleName(GenConfig.getPackageName()));
|
||||||
|
|
@ -32,47 +31,37 @@ public class GenUtils
|
||||||
/**
|
/**
|
||||||
* 初始化列属性字段
|
* 初始化列属性字段
|
||||||
*/
|
*/
|
||||||
public static void initColumnField(GenTableColumn column, GenTable table)
|
public static void initColumnField(GenTableColumn column, GenTable table) {
|
||||||
{
|
|
||||||
String dataType = getDbType(column.getColumnType());
|
String dataType = getDbType(column.getColumnType());
|
||||||
String columnName = column.getColumnName();
|
String columnName = column.getColumnName();
|
||||||
column.setTableId(table.getTableId());
|
column.setTableId(table.getTableId());
|
||||||
column.setCreateBy(table.getCreateBy());
|
column.setCreateBy(table.getCreateBy());
|
||||||
// 设置java字段名
|
// 设置java字段名
|
||||||
column.setJavaField(StringUtils.toCamelCase(columnName));
|
column.setJavaField(StringUtils.toCamelCase(columnName));
|
||||||
// 设置默认类型
|
|
||||||
column.setJavaType(GenConstants.TYPE_STRING);
|
|
||||||
|
|
||||||
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType) || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType))
|
if (arraysContains(GenConstants.COLUMNTYPE_STR, dataType)) {
|
||||||
{
|
column.setJavaType(GenConstants.TYPE_STRING);
|
||||||
// 字符串长度超过500设置为文本域
|
// 字符串长度超过500设置为文本域
|
||||||
Integer columnLength = getColumnLength(column.getColumnType());
|
Integer columnLength = getColumnLength(column.getColumnType());
|
||||||
String htmlType = columnLength >= 500 || arraysContains(GenConstants.COLUMNTYPE_TEXT, dataType) ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
|
String htmlType = columnLength >= 500 ? GenConstants.HTML_TEXTAREA : GenConstants.HTML_INPUT;
|
||||||
column.setHtmlType(htmlType);
|
column.setHtmlType(htmlType);
|
||||||
}
|
} else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType)) {
|
||||||
else if (arraysContains(GenConstants.COLUMNTYPE_TIME, dataType))
|
|
||||||
{
|
|
||||||
column.setJavaType(GenConstants.TYPE_DATE);
|
column.setJavaType(GenConstants.TYPE_DATE);
|
||||||
column.setHtmlType(GenConstants.HTML_DATETIME);
|
column.setHtmlType(GenConstants.HTML_DATETIME);
|
||||||
}
|
} else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType)) {
|
||||||
else if (arraysContains(GenConstants.COLUMNTYPE_NUMBER, dataType))
|
|
||||||
{
|
|
||||||
column.setHtmlType(GenConstants.HTML_INPUT);
|
column.setHtmlType(GenConstants.HTML_INPUT);
|
||||||
|
|
||||||
// 如果是浮点型 统一用BigDecimal
|
// 如果是浮点型
|
||||||
String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
|
String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
|
||||||
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0)
|
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0) {
|
||||||
{
|
|
||||||
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
||||||
}
|
}
|
||||||
// 如果是整形
|
// 如果是整形
|
||||||
else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10)
|
else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10) {
|
||||||
{
|
|
||||||
column.setJavaType(GenConstants.TYPE_INTEGER);
|
column.setJavaType(GenConstants.TYPE_INTEGER);
|
||||||
}
|
}
|
||||||
// 长整形
|
// 长整形
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
column.setJavaType(GenConstants.TYPE_LONG);
|
column.setJavaType(GenConstants.TYPE_LONG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -81,50 +70,37 @@ public class GenUtils
|
||||||
column.setIsInsert(GenConstants.REQUIRE);
|
column.setIsInsert(GenConstants.REQUIRE);
|
||||||
|
|
||||||
// 编辑字段
|
// 编辑字段
|
||||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk())
|
if (!arraysContains(GenConstants.COLUMNNAME_NOT_EDIT, columnName) && !column.isPk()) {
|
||||||
{
|
|
||||||
column.setIsEdit(GenConstants.REQUIRE);
|
column.setIsEdit(GenConstants.REQUIRE);
|
||||||
}
|
}
|
||||||
// 列表字段
|
// 列表字段
|
||||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk())
|
if (!arraysContains(GenConstants.COLUMNNAME_NOT_LIST, columnName) && !column.isPk()) {
|
||||||
{
|
|
||||||
column.setIsList(GenConstants.REQUIRE);
|
column.setIsList(GenConstants.REQUIRE);
|
||||||
}
|
}
|
||||||
// 查询字段
|
// 查询字段
|
||||||
if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk())
|
if (!arraysContains(GenConstants.COLUMNNAME_NOT_QUERY, columnName) && !column.isPk()) {
|
||||||
{
|
|
||||||
column.setIsQuery(GenConstants.REQUIRE);
|
column.setIsQuery(GenConstants.REQUIRE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询字段类型
|
// 查询字段类型
|
||||||
if (StringUtils.endsWithIgnoreCase(columnName, "name"))
|
if (StringUtils.endsWithIgnoreCase(columnName, "name")) {
|
||||||
{
|
|
||||||
column.setQueryType(GenConstants.QUERY_LIKE);
|
column.setQueryType(GenConstants.QUERY_LIKE);
|
||||||
}
|
}
|
||||||
// 状态字段设置单选框
|
// 状态字段设置单选框
|
||||||
if (StringUtils.endsWithIgnoreCase(columnName, "status"))
|
if (StringUtils.endsWithIgnoreCase(columnName, "status")) {
|
||||||
{
|
|
||||||
column.setHtmlType(GenConstants.HTML_RADIO);
|
column.setHtmlType(GenConstants.HTML_RADIO);
|
||||||
}
|
}
|
||||||
// 类型&性别字段设置下拉框
|
// 类型&性别字段设置下拉框
|
||||||
else if (StringUtils.endsWithIgnoreCase(columnName, "type")
|
else if (StringUtils.endsWithIgnoreCase(columnName, "type")
|
||||||
|| StringUtils.endsWithIgnoreCase(columnName, "sex"))
|
|| StringUtils.endsWithIgnoreCase(columnName, "sex")) {
|
||||||
{
|
|
||||||
column.setHtmlType(GenConstants.HTML_SELECT);
|
column.setHtmlType(GenConstants.HTML_SELECT);
|
||||||
}
|
}
|
||||||
// 图片字段设置图片上传控件
|
// 文件字段设置上传控件
|
||||||
else if (StringUtils.endsWithIgnoreCase(columnName, "image"))
|
else if (StringUtils.endsWithIgnoreCase(columnName, "image")) {
|
||||||
{
|
column.setHtmlType(GenConstants.HTML_UPLOAD_IMAGE);
|
||||||
column.setHtmlType(GenConstants.HTML_IMAGE_UPLOAD);
|
|
||||||
}
|
|
||||||
// 文件字段设置文件上传控件
|
|
||||||
else if (StringUtils.endsWithIgnoreCase(columnName, "file"))
|
|
||||||
{
|
|
||||||
column.setHtmlType(GenConstants.HTML_FILE_UPLOAD);
|
|
||||||
}
|
}
|
||||||
// 内容字段设置富文本控件
|
// 内容字段设置富文本控件
|
||||||
else if (StringUtils.endsWithIgnoreCase(columnName, "content"))
|
else if (StringUtils.endsWithIgnoreCase(columnName, "content")) {
|
||||||
{
|
|
||||||
column.setHtmlType(GenConstants.HTML_EDITOR);
|
column.setHtmlType(GenConstants.HTML_EDITOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -136,8 +112,7 @@ public class GenUtils
|
||||||
* @param targetValue 值
|
* @param targetValue 值
|
||||||
* @return 是否包含
|
* @return 是否包含
|
||||||
*/
|
*/
|
||||||
public static boolean arraysContains(String[] arr, String targetValue)
|
public static boolean arraysContains(String[] arr, String targetValue) {
|
||||||
{
|
|
||||||
return Arrays.asList(arr).contains(targetValue);
|
return Arrays.asList(arr).contains(targetValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,8 +122,7 @@ public class GenUtils
|
||||||
* @param packageName 包名
|
* @param packageName 包名
|
||||||
* @return 模块名
|
* @return 模块名
|
||||||
*/
|
*/
|
||||||
public static String getModuleName(String packageName)
|
public static String getModuleName(String packageName) {
|
||||||
{
|
|
||||||
int lastIndex = packageName.lastIndexOf(".");
|
int lastIndex = packageName.lastIndexOf(".");
|
||||||
int nameLength = packageName.length();
|
int nameLength = packageName.length();
|
||||||
String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
|
String moduleName = StringUtils.substring(packageName, lastIndex + 1, nameLength);
|
||||||
|
|
@ -161,8 +135,7 @@ public class GenUtils
|
||||||
* @param tableName 表名
|
* @param tableName 表名
|
||||||
* @return 业务名
|
* @return 业务名
|
||||||
*/
|
*/
|
||||||
public static String getBusinessName(String tableName)
|
public static String getBusinessName(String tableName) {
|
||||||
{
|
|
||||||
int lastIndex = tableName.lastIndexOf("_");
|
int lastIndex = tableName.lastIndexOf("_");
|
||||||
int nameLength = tableName.length();
|
int nameLength = tableName.length();
|
||||||
String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength);
|
String businessName = StringUtils.substring(tableName, lastIndex + 1, nameLength);
|
||||||
|
|
@ -175,12 +148,10 @@ public class GenUtils
|
||||||
* @param tableName 表名称
|
* @param tableName 表名称
|
||||||
* @return 类名
|
* @return 类名
|
||||||
*/
|
*/
|
||||||
public static String convertClassName(String tableName)
|
public static String convertClassName(String tableName) {
|
||||||
{
|
|
||||||
boolean autoRemovePre = GenConfig.getAutoRemovePre();
|
boolean autoRemovePre = GenConfig.getAutoRemovePre();
|
||||||
String tablePrefix = GenConfig.getTablePrefix();
|
String tablePrefix = GenConfig.getTablePrefix();
|
||||||
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix))
|
if (autoRemovePre && StringUtils.isNotEmpty(tablePrefix)) {
|
||||||
{
|
|
||||||
String[] searchList = StringUtils.split(tablePrefix, ",");
|
String[] searchList = StringUtils.split(tablePrefix, ",");
|
||||||
tableName = replaceFirst(tableName, searchList);
|
tableName = replaceFirst(tableName, searchList);
|
||||||
}
|
}
|
||||||
|
|
@ -194,13 +165,10 @@ public class GenUtils
|
||||||
* @param searchList 替换列表
|
* @param searchList 替换列表
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String replaceFirst(String replacementm, String[] searchList)
|
public static String replaceFirst(String replacementm, String[] searchList) {
|
||||||
{
|
|
||||||
String text = replacementm;
|
String text = replacementm;
|
||||||
for (String searchString : searchList)
|
for (String searchString : searchList) {
|
||||||
{
|
if (replacementm.startsWith(searchString)) {
|
||||||
if (replacementm.startsWith(searchString))
|
|
||||||
{
|
|
||||||
text = replacementm.replaceFirst(searchString, "");
|
text = replacementm.replaceFirst(searchString, "");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -214,8 +182,7 @@ public class GenUtils
|
||||||
* @param text 需要被替换的名字
|
* @param text 需要被替换的名字
|
||||||
* @return 替换后的名字
|
* @return 替换后的名字
|
||||||
*/
|
*/
|
||||||
public static String replaceText(String text)
|
public static String replaceText(String text) {
|
||||||
{
|
|
||||||
return RegExUtils.replaceAll(text, "(?:表|若依)", "");
|
return RegExUtils.replaceAll(text, "(?:表|若依)", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -225,14 +192,10 @@ public class GenUtils
|
||||||
* @param columnType 列类型
|
* @param columnType 列类型
|
||||||
* @return 截取后的列类型
|
* @return 截取后的列类型
|
||||||
*/
|
*/
|
||||||
public static String getDbType(String columnType)
|
public static String getDbType(String columnType) {
|
||||||
{
|
if (StringUtils.indexOf(columnType, "(") > 0) {
|
||||||
if (StringUtils.indexOf(columnType, "(") > 0)
|
|
||||||
{
|
|
||||||
return StringUtils.substringBefore(columnType, "(");
|
return StringUtils.substringBefore(columnType, "(");
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return columnType;
|
return columnType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -243,15 +206,11 @@ public class GenUtils
|
||||||
* @param columnType 列类型
|
* @param columnType 列类型
|
||||||
* @return 截取后的列类型
|
* @return 截取后的列类型
|
||||||
*/
|
*/
|
||||||
public static Integer getColumnLength(String columnType)
|
public static Integer getColumnLength(String columnType) {
|
||||||
{
|
if (StringUtils.indexOf(columnType, "(") > 0) {
|
||||||
if (StringUtils.indexOf(columnType, "(") > 0)
|
|
||||||
{
|
|
||||||
String length = StringUtils.substringBetween(columnType, "(", ")");
|
String length = StringUtils.substringBetween(columnType, "(", ")");
|
||||||
return Integer.valueOf(length);
|
return Integer.valueOf(length);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,22 @@
|
||||||
package com.ruoyi.gen.util;
|
package com.ruoyi.gen.util;
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
import org.apache.velocity.app.Velocity;
|
|
||||||
import com.ruoyi.common.core.constant.Constants;
|
import com.ruoyi.common.core.constant.Constants;
|
||||||
|
import org.apache.velocity.app.Velocity;
|
||||||
|
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VelocityEngine工厂
|
* VelocityEngine工厂
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class VelocityInitializer
|
public class VelocityInitializer {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 初始化vm方法
|
* 初始化vm方法
|
||||||
*/
|
*/
|
||||||
public static void initVelocity()
|
public static void initVelocity() {
|
||||||
{
|
|
||||||
Properties p = new Properties();
|
Properties p = new Properties();
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
// 加载classpath目录下的vm文件
|
// 加载classpath目录下的vm文件
|
||||||
p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
|
||||||
// 定义字符集
|
// 定义字符集
|
||||||
|
|
@ -26,9 +24,7 @@ public class VelocityInitializer
|
||||||
p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8);
|
p.setProperty(Velocity.OUTPUT_ENCODING, Constants.UTF8);
|
||||||
// 初始化Velocity引擎,指定配置Properties
|
// 初始化Velocity引擎,指定配置Properties
|
||||||
Velocity.init(p);
|
Velocity.init(p);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,38 @@
|
||||||
package com.ruoyi.gen.util;
|
package com.ruoyi.gen.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import org.apache.velocity.VelocityContext;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.ruoyi.common.core.constant.GenConstants;
|
import com.ruoyi.common.core.constant.GenConstants;
|
||||||
import com.ruoyi.common.core.utils.DateUtils;
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
import com.ruoyi.common.core.utils.StringUtils;
|
import com.ruoyi.common.core.utils.StringUtils;
|
||||||
import com.ruoyi.gen.domain.GenTable;
|
import com.ruoyi.gen.domain.GenTable;
|
||||||
import com.ruoyi.gen.domain.GenTableColumn;
|
import com.ruoyi.gen.domain.GenTableColumn;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.velocity.VelocityContext;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 模板工具类
|
* 模板工具类
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
public class VelocityUtils
|
@Slf4j
|
||||||
{
|
public class VelocityUtils {
|
||||||
/** 项目空间路径 */
|
/**
|
||||||
private static final String PROJECT_PATH = "main/java";
|
* 项目空间路径
|
||||||
|
*/
|
||||||
|
private static final String PROJECT_PATH = "java";
|
||||||
|
|
||||||
/** mybatis空间路径 */
|
/**
|
||||||
private static final String MYBATIS_PATH = "main/resources/mapper";
|
* mybatis空间路径
|
||||||
|
*/
|
||||||
|
private static final String MYBATIS_PATH = "resources/mapper";
|
||||||
|
|
||||||
/** 默认上级菜单,系统工具 */
|
/**
|
||||||
|
* 默认上级菜单,系统工具
|
||||||
|
*/
|
||||||
private static final String DEFAULT_PARENT_MENU_ID = "3";
|
private static final String DEFAULT_PARENT_MENU_ID = "3";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -32,8 +40,7 @@ public class VelocityUtils
|
||||||
*
|
*
|
||||||
* @return 模板列表
|
* @return 模板列表
|
||||||
*/
|
*/
|
||||||
public static VelocityContext prepareContext(GenTable genTable)
|
public static VelocityContext prepareContext(GenTable genTable) {
|
||||||
{
|
|
||||||
String moduleName = genTable.getModuleName();
|
String moduleName = genTable.getModuleName();
|
||||||
String businessName = genTable.getBusinessName();
|
String businessName = genTable.getBusinessName();
|
||||||
String packageName = genTable.getPackageName();
|
String packageName = genTable.getPackageName();
|
||||||
|
|
@ -54,32 +61,25 @@ public class VelocityUtils
|
||||||
velocityContext.put("author", genTable.getFunctionAuthor());
|
velocityContext.put("author", genTable.getFunctionAuthor());
|
||||||
velocityContext.put("datetime", DateUtils.getDate());
|
velocityContext.put("datetime", DateUtils.getDate());
|
||||||
velocityContext.put("pkColumn", genTable.getPkColumn());
|
velocityContext.put("pkColumn", genTable.getPkColumn());
|
||||||
velocityContext.put("importList", getImportList(genTable));
|
velocityContext.put("importList", getImportList(genTable.getColumns()));
|
||||||
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
|
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName, businessName));
|
||||||
velocityContext.put("columns", genTable.getColumns());
|
velocityContext.put("columns", genTable.getColumns());
|
||||||
velocityContext.put("table", genTable);
|
velocityContext.put("table", genTable);
|
||||||
setMenuVelocityContext(velocityContext, genTable);
|
setMenuVelocityContext(velocityContext, genTable);
|
||||||
if (GenConstants.TPL_TREE.equals(tplCategory))
|
if (GenConstants.TPL_TREE.equals(tplCategory)) {
|
||||||
{
|
|
||||||
setTreeVelocityContext(velocityContext, genTable);
|
setTreeVelocityContext(velocityContext, genTable);
|
||||||
}
|
}
|
||||||
if (GenConstants.TPL_SUB.equals(tplCategory))
|
|
||||||
{
|
|
||||||
setSubVelocityContext(velocityContext, genTable);
|
|
||||||
}
|
|
||||||
return velocityContext;
|
return velocityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable)
|
public static void setMenuVelocityContext(VelocityContext context, GenTable genTable) {
|
||||||
{
|
|
||||||
String options = genTable.getOptions();
|
String options = genTable.getOptions();
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
JSONObject paramsObj = JSONObject.parseObject(options);
|
||||||
String parentMenuId = getParentMenuId(paramsObj);
|
String parentMenuId = getParentMenuId(paramsObj);
|
||||||
context.put("parentMenuId", parentMenuId);
|
context.put("parentMenuId", parentMenuId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable)
|
public static void setTreeVelocityContext(VelocityContext context, GenTable genTable) {
|
||||||
{
|
|
||||||
String options = genTable.getOptions();
|
String options = genTable.getOptions();
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
JSONObject paramsObj = JSONObject.parseObject(options);
|
||||||
String treeCode = getTreecode(paramsObj);
|
String treeCode = getTreecode(paramsObj);
|
||||||
|
|
@ -90,71 +90,48 @@ public class VelocityUtils
|
||||||
context.put("treeParentCode", treeParentCode);
|
context.put("treeParentCode", treeParentCode);
|
||||||
context.put("treeName", treeName);
|
context.put("treeName", treeName);
|
||||||
context.put("expandColumn", getExpandColumn(genTable));
|
context.put("expandColumn", getExpandColumn(genTable));
|
||||||
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
|
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
|
||||||
{
|
|
||||||
context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
context.put("tree_parent_code", paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
||||||
}
|
}
|
||||||
if (paramsObj.containsKey(GenConstants.TREE_NAME))
|
if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
|
||||||
{
|
|
||||||
context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME));
|
context.put("tree_name", paramsObj.getString(GenConstants.TREE_NAME));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSubVelocityContext(VelocityContext context, GenTable genTable)
|
|
||||||
{
|
|
||||||
GenTable subTable = genTable.getSubTable();
|
|
||||||
String subTableName = genTable.getSubTableName();
|
|
||||||
String subTableFkName = genTable.getSubTableFkName();
|
|
||||||
String subClassName = genTable.getSubTable().getClassName();
|
|
||||||
String subTableFkClassName = StringUtils.convertToCamelCase(subTableFkName);
|
|
||||||
|
|
||||||
context.put("subTable", subTable);
|
|
||||||
context.put("subTableName", subTableName);
|
|
||||||
context.put("subTableFkName", subTableFkName);
|
|
||||||
context.put("subTableFkClassName", subTableFkClassName);
|
|
||||||
context.put("subTableFkclassName", StringUtils.uncapitalize(subTableFkClassName));
|
|
||||||
context.put("subClassName", subClassName);
|
|
||||||
context.put("subclassName", StringUtils.uncapitalize(subClassName));
|
|
||||||
context.put("subImportList", getImportList(genTable.getSubTable()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取模板信息
|
* 获取模板信息
|
||||||
*
|
*
|
||||||
* @return 模板列表
|
* @return 模板列表
|
||||||
*/
|
*/
|
||||||
public static List<String> getTemplateList(String tplCategory)
|
public static List<String> getTemplateList(String tplCategory) {
|
||||||
{
|
|
||||||
List<String> templates = new ArrayList<String>();
|
List<String> templates = new ArrayList<String>();
|
||||||
templates.add("vm/java/domain.java.vm");
|
// templates.add("vm/java/domain.java.vm");
|
||||||
templates.add("vm/java/mapper.java.vm");
|
// templates.add("vm/java/mapper.java.vm");
|
||||||
templates.add("vm/java/service.java.vm");
|
// templates.add("vm/java/service.java.vm");
|
||||||
templates.add("vm/java/serviceImpl.java.vm");
|
// templates.add("vm/java/serviceImpl.java.vm");
|
||||||
templates.add("vm/java/controller.java.vm");
|
// templates.add("vm/java/controller.java.vm");
|
||||||
|
|
||||||
|
templates.add("vm/java-plus/domain.java.vm");
|
||||||
|
templates.add("vm/java-plus/mapper.java.vm");
|
||||||
|
templates.add("vm/java-plus/service.java.vm");
|
||||||
|
templates.add("vm/java-plus/serviceImpl.java.vm");
|
||||||
|
templates.add("vm/java-plus/controller.java.vm");
|
||||||
|
|
||||||
templates.add("vm/xml/mapper.xml.vm");
|
templates.add("vm/xml/mapper.xml.vm");
|
||||||
templates.add("vm/sql/sql.vm");
|
templates.add("vm/sql/sql.vm");
|
||||||
templates.add("vm/js/api.js.vm");
|
templates.add("vm/js/api.js.vm");
|
||||||
if (GenConstants.TPL_CRUD.equals(tplCategory))
|
if (GenConstants.TPL_CRUD.equals(tplCategory)) {
|
||||||
{
|
|
||||||
templates.add("vm/vue/index.vue.vm");
|
templates.add("vm/vue/index.vue.vm");
|
||||||
}
|
} else if (GenConstants.TPL_TREE.equals(tplCategory)) {
|
||||||
else if (GenConstants.TPL_TREE.equals(tplCategory))
|
|
||||||
{
|
|
||||||
templates.add("vm/vue/index-tree.vue.vm");
|
templates.add("vm/vue/index-tree.vue.vm");
|
||||||
}
|
}
|
||||||
else if (GenConstants.TPL_SUB.equals(tplCategory))
|
|
||||||
{
|
|
||||||
templates.add("vm/vue/index.vue.vm");
|
|
||||||
templates.add("vm/java/sub-domain.java.vm");
|
|
||||||
}
|
|
||||||
return templates;
|
return templates;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取文件名
|
* 获取文件名
|
||||||
*/
|
*/
|
||||||
public static String getFileName(String template, GenTable genTable)
|
public static String getFileName(String template, GenTable genTable) {
|
||||||
{
|
|
||||||
// 文件名称
|
// 文件名称
|
||||||
String fileName = "";
|
String fileName = "";
|
||||||
// 包路径
|
// 包路径
|
||||||
|
|
@ -170,48 +147,25 @@ public class VelocityUtils
|
||||||
String mybatisPath = MYBATIS_PATH + "/" + moduleName;
|
String mybatisPath = MYBATIS_PATH + "/" + moduleName;
|
||||||
String vuePath = "vue";
|
String vuePath = "vue";
|
||||||
|
|
||||||
if (template.contains("domain.java.vm"))
|
if (template.contains("domain.java.vm")) {
|
||||||
{
|
|
||||||
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
|
fileName = StringUtils.format("{}/domain/{}.java", javaPath, className);
|
||||||
}
|
} else if (template.contains("mapper.java.vm")) {
|
||||||
if (template.contains("sub-domain.java.vm") && StringUtils.equals(GenConstants.TPL_SUB, genTable.getTplCategory()))
|
fileName = StringUtils.format("{}/dao.mysql/{}Mapper.java", javaPath, className);
|
||||||
{
|
} else if (template.contains("service.java.vm")) {
|
||||||
fileName = StringUtils.format("{}/domain/{}.java", javaPath, genTable.getSubTable().getClassName());
|
fileName = StringUtils.format("{}/service/{}Service.java", javaPath, className);
|
||||||
}
|
} else if (template.contains("serviceImpl.java.vm")) {
|
||||||
else if (template.contains("mapper.java.vm"))
|
|
||||||
{
|
|
||||||
fileName = StringUtils.format("{}/mapper/{}Mapper.java", javaPath, className);
|
|
||||||
}
|
|
||||||
else if (template.contains("service.java.vm"))
|
|
||||||
{
|
|
||||||
fileName = StringUtils.format("{}/service/I{}Service.java", javaPath, className);
|
|
||||||
}
|
|
||||||
else if (template.contains("serviceImpl.java.vm"))
|
|
||||||
{
|
|
||||||
fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
|
fileName = StringUtils.format("{}/service/impl/{}ServiceImpl.java", javaPath, className);
|
||||||
}
|
} else if (template.contains("controller.java.vm")) {
|
||||||
else if (template.contains("controller.java.vm"))
|
|
||||||
{
|
|
||||||
fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
|
fileName = StringUtils.format("{}/controller/{}Controller.java", javaPath, className);
|
||||||
}
|
} else if (template.contains("mapper.xml.vm")) {
|
||||||
else if (template.contains("mapper.xml.vm"))
|
|
||||||
{
|
|
||||||
fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
|
fileName = StringUtils.format("{}/{}Mapper.xml", mybatisPath, className);
|
||||||
}
|
} else if (template.contains("sql.vm")) {
|
||||||
else if (template.contains("sql.vm"))
|
|
||||||
{
|
|
||||||
fileName = businessName + "Menu.sql";
|
fileName = businessName + "Menu.sql";
|
||||||
}
|
} else if (template.contains("api.js.vm")) {
|
||||||
else if (template.contains("api.js.vm"))
|
|
||||||
{
|
|
||||||
fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
|
fileName = StringUtils.format("{}/api/{}/{}.js", vuePath, moduleName, businessName);
|
||||||
}
|
} else if (template.contains("index.vue.vm")) {
|
||||||
else if (template.contains("index.vue.vm"))
|
|
||||||
{
|
|
||||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||||
}
|
} else if (template.contains("index-tree.vue.vm")) {
|
||||||
else if (template.contains("index-tree.vue.vm"))
|
|
||||||
{
|
|
||||||
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
fileName = StringUtils.format("{}/views/{}/{}/index.vue", vuePath, moduleName, businessName);
|
||||||
}
|
}
|
||||||
return fileName;
|
return fileName;
|
||||||
|
|
@ -223,8 +177,7 @@ public class VelocityUtils
|
||||||
* @param packageName 包名称
|
* @param packageName 包名称
|
||||||
* @return 包前缀名称
|
* @return 包前缀名称
|
||||||
*/
|
*/
|
||||||
public static String getPackagePrefix(String packageName)
|
public static String getPackagePrefix(String packageName) {
|
||||||
{
|
|
||||||
int lastIndex = packageName.lastIndexOf(".");
|
int lastIndex = packageName.lastIndexOf(".");
|
||||||
String basePackage = StringUtils.substring(packageName, 0, lastIndex);
|
String basePackage = StringUtils.substring(packageName, 0, lastIndex);
|
||||||
return basePackage;
|
return basePackage;
|
||||||
|
|
@ -233,27 +186,16 @@ public class VelocityUtils
|
||||||
/**
|
/**
|
||||||
* 根据列类型获取导入包
|
* 根据列类型获取导入包
|
||||||
*
|
*
|
||||||
* @param genTable 业务表对象
|
* @param columns 列集合
|
||||||
* @return 返回需要导入的包列表
|
* @return 返回需要导入的包列表
|
||||||
*/
|
*/
|
||||||
public static HashSet<String> getImportList(GenTable genTable)
|
public static HashSet<String> getImportList(List<GenTableColumn> columns) {
|
||||||
{
|
|
||||||
List<GenTableColumn> columns = genTable.getColumns();
|
|
||||||
GenTable subGenTable = genTable.getSubTable();
|
|
||||||
HashSet<String> importList = new HashSet<String>();
|
HashSet<String> importList = new HashSet<String>();
|
||||||
if (StringUtils.isNotNull(subGenTable))
|
for (GenTableColumn column : columns) {
|
||||||
{
|
if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType())) {
|
||||||
importList.add("java.util.List");
|
|
||||||
}
|
|
||||||
for (GenTableColumn column : columns)
|
|
||||||
{
|
|
||||||
if (!column.isSuperColumn() && GenConstants.TYPE_DATE.equals(column.getJavaType()))
|
|
||||||
{
|
|
||||||
importList.add("java.util.Date");
|
importList.add("java.util.Date");
|
||||||
importList.add("com.fasterxml.jackson.annotation.JsonFormat");
|
importList.add("com.fasterxml.jackson.annotation.JsonFormat");
|
||||||
}
|
} else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType())) {
|
||||||
else if (!column.isSuperColumn() && GenConstants.TYPE_BIGDECIMAL.equals(column.getJavaType()))
|
|
||||||
{
|
|
||||||
importList.add("java.math.BigDecimal");
|
importList.add("java.math.BigDecimal");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -267,8 +209,7 @@ public class VelocityUtils
|
||||||
* @param businessName 业务名称
|
* @param businessName 业务名称
|
||||||
* @return 返回权限前缀
|
* @return 返回权限前缀
|
||||||
*/
|
*/
|
||||||
public static String getPermissionPrefix(String moduleName, String businessName)
|
public static String getPermissionPrefix(String moduleName, String businessName) {
|
||||||
{
|
|
||||||
return StringUtils.format("{}:{}", moduleName, businessName);
|
return StringUtils.format("{}:{}", moduleName, businessName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -278,10 +219,8 @@ public class VelocityUtils
|
||||||
* @param paramsObj 生成其他选项
|
* @param paramsObj 生成其他选项
|
||||||
* @return 上级菜单ID字段
|
* @return 上级菜单ID字段
|
||||||
*/
|
*/
|
||||||
public static String getParentMenuId(JSONObject paramsObj)
|
public static String getParentMenuId(JSONObject paramsObj) {
|
||||||
{
|
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID)) {
|
||||||
if (StringUtils.isNotEmpty(paramsObj) && paramsObj.containsKey(GenConstants.PARENT_MENU_ID))
|
|
||||||
{
|
|
||||||
return paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
return paramsObj.getString(GenConstants.PARENT_MENU_ID);
|
||||||
}
|
}
|
||||||
return DEFAULT_PARENT_MENU_ID;
|
return DEFAULT_PARENT_MENU_ID;
|
||||||
|
|
@ -293,10 +232,8 @@ public class VelocityUtils
|
||||||
* @param paramsObj 生成其他选项
|
* @param paramsObj 生成其他选项
|
||||||
* @return 树编码
|
* @return 树编码
|
||||||
*/
|
*/
|
||||||
public static String getTreecode(JSONObject paramsObj)
|
public static String getTreecode(JSONObject paramsObj) {
|
||||||
{
|
if (paramsObj.containsKey(GenConstants.TREE_CODE)) {
|
||||||
if (paramsObj.containsKey(GenConstants.TREE_CODE))
|
|
||||||
{
|
|
||||||
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
|
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_CODE));
|
||||||
}
|
}
|
||||||
return StringUtils.EMPTY;
|
return StringUtils.EMPTY;
|
||||||
|
|
@ -308,10 +245,8 @@ public class VelocityUtils
|
||||||
* @param paramsObj 生成其他选项
|
* @param paramsObj 生成其他选项
|
||||||
* @return 树父编码
|
* @return 树父编码
|
||||||
*/
|
*/
|
||||||
public static String getTreeParentCode(JSONObject paramsObj)
|
public static String getTreeParentCode(JSONObject paramsObj) {
|
||||||
{
|
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE)) {
|
||||||
if (paramsObj.containsKey(GenConstants.TREE_PARENT_CODE))
|
|
||||||
{
|
|
||||||
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_PARENT_CODE));
|
||||||
}
|
}
|
||||||
return StringUtils.EMPTY;
|
return StringUtils.EMPTY;
|
||||||
|
|
@ -323,10 +258,8 @@ public class VelocityUtils
|
||||||
* @param paramsObj 生成其他选项
|
* @param paramsObj 生成其他选项
|
||||||
* @return 树名称
|
* @return 树名称
|
||||||
*/
|
*/
|
||||||
public static String getTreeName(JSONObject paramsObj)
|
public static String getTreeName(JSONObject paramsObj) {
|
||||||
{
|
if (paramsObj.containsKey(GenConstants.TREE_NAME)) {
|
||||||
if (paramsObj.containsKey(GenConstants.TREE_NAME))
|
|
||||||
{
|
|
||||||
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
|
return StringUtils.toCamelCase(paramsObj.getString(GenConstants.TREE_NAME));
|
||||||
}
|
}
|
||||||
return StringUtils.EMPTY;
|
return StringUtils.EMPTY;
|
||||||
|
|
@ -338,20 +271,16 @@ public class VelocityUtils
|
||||||
* @param genTable 业务表对象
|
* @param genTable 业务表对象
|
||||||
* @return 展开按钮列序号
|
* @return 展开按钮列序号
|
||||||
*/
|
*/
|
||||||
public static int getExpandColumn(GenTable genTable)
|
public static int getExpandColumn(GenTable genTable) {
|
||||||
{
|
|
||||||
String options = genTable.getOptions();
|
String options = genTable.getOptions();
|
||||||
JSONObject paramsObj = JSONObject.parseObject(options);
|
JSONObject paramsObj = JSONObject.parseObject(options);
|
||||||
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
String treeName = paramsObj.getString(GenConstants.TREE_NAME);
|
||||||
int num = 0;
|
int num = 0;
|
||||||
for (GenTableColumn column : genTable.getColumns())
|
for (GenTableColumn column : genTable.getColumns()) {
|
||||||
{
|
if (column.isList()) {
|
||||||
if (column.isList())
|
|
||||||
{
|
|
||||||
num++;
|
num++;
|
||||||
String columnName = column.getColumnName();
|
String columnName = column.getColumnName();
|
||||||
if (columnName.equals(treeName))
|
if (columnName.equals(treeName)) {
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,38 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "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.ruoyi.gen.mapper.GenTableColumnMapper">
|
<mapper namespace="com.ruoyi.gen.mapper.GenTableColumnMapper">
|
||||||
|
|
||||||
<resultMap type="GenTableColumn" id="GenTableColumnResult">
|
<resultMap type="com.ruoyi.gen.domain.GenTableColumn" id="GenTableColumnResult">
|
||||||
<id property="columnId" column="column_id" />
|
<id property="columnId" column="column_id"/>
|
||||||
<result property="tableId" column="table_id" />
|
<result property="tableId" column="table_id"/>
|
||||||
<result property="columnName" column="column_name" />
|
<result property="columnName" column="column_name"/>
|
||||||
<result property="columnComment" column="column_comment" />
|
<result property="columnComment" column="column_comment"/>
|
||||||
<result property="columnType" column="column_type" />
|
<result property="columnType" column="column_type"/>
|
||||||
<result property="javaType" column="java_type" />
|
<result property="javaType" column="java_type"/>
|
||||||
<result property="javaField" column="java_field" />
|
<result property="javaField" column="java_field"/>
|
||||||
<result property="isPk" column="is_pk" />
|
<result property="isPk" column="is_pk"/>
|
||||||
<result property="isIncrement" column="is_increment" />
|
<result property="isIncrement" column="is_increment"/>
|
||||||
<result property="isRequired" column="is_required" />
|
<result property="isRequired" column="is_required"/>
|
||||||
<result property="isInsert" column="is_insert" />
|
<result property="isInsert" column="is_insert"/>
|
||||||
<result property="isEdit" column="is_edit" />
|
<result property="isEdit" column="is_edit"/>
|
||||||
<result property="isList" column="is_list" />
|
<result property="isList" column="is_list"/>
|
||||||
<result property="isQuery" column="is_query" />
|
<result property="isQuery" column="is_query"/>
|
||||||
<result property="queryType" column="query_type" />
|
<result property="queryType" column="query_type"/>
|
||||||
<result property="htmlType" column="html_type" />
|
<result property="htmlType" column="html_type"/>
|
||||||
<result property="dictType" column="dict_type" />
|
<result property="dictType" column="dict_type"/>
|
||||||
<result property="sort" column="sort" />
|
<result property="sort" column="sort"/>
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by"/>
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time"/>
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by"/>
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectGenTableColumnVo">
|
<sql id="selectGenTableColumnVo">
|
||||||
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
|
select column_id, table_id, column_name, column_comment, column_type, java_type, java_field, is_pk, is_increment, is_required, is_insert, is_edit, is_list, is_query, query_type, html_type, dict_type, sort, create_by, create_time, update_by, update_time from gen_table_column
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectGenTableColumnListByTableId" parameterType="GenTableColumn" resultMap="GenTableColumnResult">
|
<select id="selectGenTableColumnListByTableId" parameterType="com.ruoyi.gen.domain.GenTableColumn"
|
||||||
|
resultMap="GenTableColumnResult">
|
||||||
<include refid="selectGenTableColumnVo"/>
|
<include refid="selectGenTableColumnVo"/>
|
||||||
where table_id = #{tableId}
|
where table_id = #{tableId}
|
||||||
order by sort
|
order by sort
|
||||||
|
|
@ -45,7 +44,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
order by ordinal_position
|
order by ordinal_position
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertGenTableColumn" parameterType="GenTableColumn" useGeneratedKeys="true" keyProperty="columnId">
|
<insert id="insertGenTableColumn" parameterType="com.ruoyi.gen.domain.GenTableColumn" useGeneratedKeys="true"
|
||||||
|
keyProperty="columnId">
|
||||||
insert into gen_table_column (
|
insert into gen_table_column (
|
||||||
<if test="tableId != null and tableId != ''">table_id,</if>
|
<if test="tableId != null and tableId != ''">table_id,</if>
|
||||||
<if test="columnName != null and columnName != ''">column_name,</if>
|
<if test="columnName != null and columnName != ''">column_name,</if>
|
||||||
|
|
@ -89,7 +89,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateGenTableColumn" parameterType="GenTableColumn">
|
<update id="updateGenTableColumn" parameterType="com.ruoyi.gen.domain.GenTableColumn">
|
||||||
update gen_table_column
|
update gen_table_column
|
||||||
<set>
|
<set>
|
||||||
column_comment = #{columnComment},
|
column_comment = #{columnComment},
|
||||||
|
|
|
||||||
|
|
@ -1,63 +1,59 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "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.ruoyi.gen.mapper.GenTableMapper">
|
<mapper namespace="com.ruoyi.gen.mapper.GenTableMapper">
|
||||||
|
|
||||||
<resultMap type="GenTable" id="GenTableResult">
|
<resultMap type="com.ruoyi.gen.domain.GenTable" id="GenTableResult">
|
||||||
<id property="tableId" column="table_id" />
|
<id property="tableId" column="table_id"/>
|
||||||
<result property="tableName" column="table_name" />
|
<result property="tableName" column="table_name"/>
|
||||||
<result property="tableComment" column="table_comment" />
|
<result property="tableComment" column="table_comment"/>
|
||||||
<result property="subTableName" column="sub_table_name" />
|
<result property="className" column="class_name"/>
|
||||||
<result property="subTableFkName" column="sub_table_fk_name" />
|
<result property="tplCategory" column="tpl_category"/>
|
||||||
<result property="className" column="class_name" />
|
<result property="packageName" column="package_name"/>
|
||||||
<result property="tplCategory" column="tpl_category" />
|
<result property="moduleName" column="module_name"/>
|
||||||
<result property="packageName" column="package_name" />
|
<result property="businessName" column="business_name"/>
|
||||||
<result property="moduleName" column="module_name" />
|
<result property="functionName" column="function_name"/>
|
||||||
<result property="businessName" column="business_name" />
|
<result property="functionAuthor" column="function_author"/>
|
||||||
<result property="functionName" column="function_name" />
|
<result property="genType" column="gen_type"/>
|
||||||
<result property="functionAuthor" column="function_author" />
|
<result property="genPath" column="gen_path"/>
|
||||||
<result property="genType" column="gen_type" />
|
<result property="options" column="options"/>
|
||||||
<result property="genPath" column="gen_path" />
|
<result property="createBy" column="create_by"/>
|
||||||
<result property="options" column="options" />
|
<result property="createTime" column="create_time"/>
|
||||||
<result property="createBy" column="create_by" />
|
<result property="updateBy" column="update_by"/>
|
||||||
<result property="createTime" column="create_time" />
|
<result property="updateTime" column="update_time"/>
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="remark" column="remark"/>
|
||||||
<result property="updateTime" column="update_time" />
|
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult"/>
|
||||||
<result property="remark" column="remark" />
|
|
||||||
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<resultMap type="GenTableColumn" id="GenTableColumnResult">
|
<resultMap type="com.ruoyi.gen.domain.GenTableColumn" id="GenTableColumnResult">
|
||||||
<id property="columnId" column="column_id" />
|
<id property="columnId" column="column_id"/>
|
||||||
<result property="tableId" column="table_id" />
|
<result property="tableId" column="table_id"/>
|
||||||
<result property="columnName" column="column_name" />
|
<result property="columnName" column="column_name"/>
|
||||||
<result property="columnComment" column="column_comment" />
|
<result property="columnComment" column="column_comment"/>
|
||||||
<result property="columnType" column="column_type" />
|
<result property="columnType" column="column_type"/>
|
||||||
<result property="javaType" column="java_type" />
|
<result property="javaType" column="java_type"/>
|
||||||
<result property="javaField" column="java_field" />
|
<result property="javaField" column="java_field"/>
|
||||||
<result property="isPk" column="is_pk" />
|
<result property="isPk" column="is_pk"/>
|
||||||
<result property="isIncrement" column="is_increment" />
|
<result property="isIncrement" column="is_increment"/>
|
||||||
<result property="isRequired" column="is_required" />
|
<result property="isRequired" column="is_required"/>
|
||||||
<result property="isInsert" column="is_insert" />
|
<result property="isInsert" column="is_insert"/>
|
||||||
<result property="isEdit" column="is_edit" />
|
<result property="isEdit" column="is_edit"/>
|
||||||
<result property="isList" column="is_list" />
|
<result property="isList" column="is_list"/>
|
||||||
<result property="isQuery" column="is_query" />
|
<result property="isQuery" column="is_query"/>
|
||||||
<result property="queryType" column="query_type" />
|
<result property="queryType" column="query_type"/>
|
||||||
<result property="htmlType" column="html_type" />
|
<result property="htmlType" column="html_type"/>
|
||||||
<result property="dictType" column="dict_type" />
|
<result property="dictType" column="dict_type"/>
|
||||||
<result property="sort" column="sort" />
|
<result property="sort" column="sort"/>
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by"/>
|
||||||
<result property="createTime" column="create_time" />
|
<result property="createTime" column="create_time"/>
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by"/>
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectGenTableVo">
|
<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
|
select table_id, table_name, table_comment, 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>
|
||||||
|
|
||||||
<select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
|
<select id="selectGenTableList" parameterType="com.ruoyi.gen.domain.GenTable" resultMap="GenTableResult">
|
||||||
<include refid="selectGenTableVo"/>
|
<include refid="selectGenTableVo"/>
|
||||||
<where>
|
<where>
|
||||||
<if test="tableName != null and tableName != ''">
|
<if test="tableName != null and tableName != ''">
|
||||||
|
|
@ -75,7 +71,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
|
<select id="selectDbTableList" parameterType="com.ruoyi.gen.domain.GenTable" resultMap="GenTableResult">
|
||||||
select table_name, table_comment, create_time, update_time from information_schema.tables
|
select table_name, table_comment, create_time, update_time from information_schema.tables
|
||||||
where table_schema = (select database())
|
where table_schema = (select database())
|
||||||
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
|
AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
|
||||||
|
|
@ -86,12 +82,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="tableComment != null and tableComment != ''">
|
<if test="tableComment != null and tableComment != ''">
|
||||||
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
|
||||||
</if>
|
</if>
|
||||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
|
||||||
AND date_format(create_time,'%y%m%d') >= date_format(#{params.beginTime},'%y%m%d')
|
|
||||||
</if>
|
|
||||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
|
||||||
AND date_format(create_time,'%y%m%d') <= date_format(#{params.endTime},'%y%m%d')
|
|
||||||
</if>
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectDbTableListByNames" resultMap="GenTableResult">
|
<select id="selectDbTableListByNames" resultMap="GenTableResult">
|
||||||
|
|
@ -110,7 +100,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
SELECT t.table_id, t.table_name, t.table_comment, 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
|
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
|
FROM gen_table t
|
||||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||||
|
|
@ -118,22 +108,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
|
||||||
SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
|
SELECT t.table_id, t.table_name, t.table_comment, 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
|
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
|
FROM gen_table t
|
||||||
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
LEFT JOIN gen_table_column c ON t.table_id = c.table_id
|
||||||
where t.table_name = #{tableName} order by c.sort
|
where t.table_name = #{tableName} order by c.sort
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
|
<insert id="insertGenTable" parameterType="com.ruoyi.gen.domain.GenTable" useGeneratedKeys="true"
|
||||||
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,
|
keyProperty="tableId">
|
||||||
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>
|
|
||||||
|
|
||||||
<insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
|
|
||||||
insert into gen_table (
|
insert into gen_table (
|
||||||
<if test="tableName != null">table_name,</if>
|
<if test="tableName != null">table_name,</if>
|
||||||
<if test="tableComment != null and tableComment != ''">table_comment,</if>
|
<if test="tableComment != null and tableComment != ''">table_comment,</if>
|
||||||
|
|
@ -167,13 +150,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateGenTable" parameterType="GenTable">
|
<update id="updateGenTable" parameterType="com.ruoyi.gen.domain.GenTable">
|
||||||
update gen_table
|
update gen_table
|
||||||
<set>
|
<set>
|
||||||
<if test="tableName != null">table_name = #{tableName},</if>
|
<if test="tableName != null">table_name = #{tableName},</if>
|
||||||
<if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
|
<if test="tableComment != null and tableComment != ''">table_comment = #{tableComment},</if>
|
||||||
<if test="subTableName != null">sub_table_name = #{subTableName},</if>
|
|
||||||
<if test="subTableFkName != null">sub_table_fk_name = #{subTableFkName},</if>
|
|
||||||
<if test="className != null and className != ''">class_name = #{className},</if>
|
<if test="className != null and className != ''">class_name = #{className},</if>
|
||||||
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
|
<if test="functionAuthor != null and functionAuthor != ''">function_author = #{functionAuthor},</if>
|
||||||
<if test="genType != null and genType != ''">gen_type = #{genType},</if>
|
<if test="genType != null and genType != ''">gen_type = #{genType},</if>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,119 @@
|
||||||
|
package ${packageName}.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
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.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.security.annotation.PreAuthorize;
|
||||||
|
import ${packageName}.domain.${ClassName};
|
||||||
|
import ${packageName}.service.${ClassName}Service;
|
||||||
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||||
|
#if($table.crud)
|
||||||
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
#elseif($table.tree)
|
||||||
|
#end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ${functionName}Controller
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @date ${datetime}
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/${businessName}")
|
||||||
|
public class ${ClassName}Controller extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ${ClassName}Service ${className}Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询${functionName}列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize(hasPermi = "${permissionPrefix}:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
#if($table.crud)
|
||||||
|
public TableDataInfo list(${ClassName} ${className})
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<${ClassName}> list = ${className}Service.list(new QueryWrapper<>(${className}));
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
#elseif($table.tree)
|
||||||
|
public AjaxResult list(${ClassName} ${className})
|
||||||
|
{
|
||||||
|
List<${ClassName}> list = ${className}Service.list(new QueryWrapper<>(${className}));
|
||||||
|
return AjaxResult.success(list);
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出${functionName}列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize(hasPermi = "${permissionPrefix}:export")
|
||||||
|
@Log(title = "${functionName}", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, ${ClassName} ${className}) throws IOException
|
||||||
|
{
|
||||||
|
List<${ClassName}> list = ${className}Service.list(new QueryWrapper<>(${className}));
|
||||||
|
ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
|
||||||
|
util.exportExcel(response, list, "${businessName}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取${functionName}详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize(hasPermi = "${permissionPrefix}:query")
|
||||||
|
@GetMapping(value = "/{${pkColumn.javaField}}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
|
||||||
|
{
|
||||||
|
return AjaxResult.success(${className}Service.getById(${pkColumn.javaField}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增${functionName}
|
||||||
|
*/
|
||||||
|
@PreAuthorize(hasPermi = "${permissionPrefix}:add")
|
||||||
|
@Log(title = "${functionName}", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody ${ClassName} ${className})
|
||||||
|
{
|
||||||
|
return toAjax(${className}Service.save(${className}) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改${functionName}
|
||||||
|
*/
|
||||||
|
@PreAuthorize(hasPermi = "${permissionPrefix}:edit")
|
||||||
|
@Log(title = "${functionName}", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody ${ClassName} ${className})
|
||||||
|
{
|
||||||
|
return toAjax(${className}Service.update(new UpdateWrapper(${className})) ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除${functionName}
|
||||||
|
*/
|
||||||
|
@PreAuthorize(hasPermi = "${permissionPrefix}:remove")
|
||||||
|
@Log(title = "${functionName}", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{${pkColumn.javaField}s}")
|
||||||
|
public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
|
||||||
|
{
|
||||||
|
return toAjax(${className}Service.removeByIds(Set.of(${pkColumn.javaField}s)) ? ${pkColumn.javaField}s.length : 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
package ${packageName}.domain;
|
||||||
|
|
||||||
|
#foreach ($import in $importList)
|
||||||
|
import ${import};
|
||||||
|
#end
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.ruoyi.common.core.annotation.Excel;
|
||||||
|
#if($table.crud)
|
||||||
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
|
#elseif($table.tree)
|
||||||
|
import com.ruoyi.common.core.web.domain.TreeEntity;
|
||||||
|
#end
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Builder;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
/**
|
||||||
|
* ${functionName}对象 ${tableName}
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @date ${datetime}
|
||||||
|
*/
|
||||||
|
#if($table.crud)
|
||||||
|
#set($Entity="BaseEntity")
|
||||||
|
#elseif($table.tree)
|
||||||
|
#set($Entity="TreeEntity")
|
||||||
|
#end
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@TableName("${tableName}")
|
||||||
|
public class ${ClassName} extends ${Entity}
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if(!$table.isSuperColumn($column.javaField))
|
||||||
|
/** $column.columnComment */
|
||||||
|
#if($column.list)
|
||||||
|
#set($parentheseIndex=$column.columnComment.indexOf("("))
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
#set($comment=$column.columnComment.substring(0, $parentheseIndex))
|
||||||
|
#else
|
||||||
|
#set($comment=$column.columnComment)
|
||||||
|
#end
|
||||||
|
#if($parentheseIndex != -1)
|
||||||
|
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
|
||||||
|
#elseif($column.javaType == 'Date')
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
|
#else
|
||||||
|
@Excel(name = "${comment}")
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
private $column.javaType $column.javaField;
|
||||||
|
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
package ${packageName}.dao.mysql;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import ${packageName}.domain.${ClassName};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ${functionName}Mapper接口
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @date ${datetime}
|
||||||
|
*/
|
||||||
|
public interface ${ClassName}Mapper extends BaseMapper<${ClassName}> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package ${packageName}.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import ${packageName}.domain.${ClassName};
|
||||||
|
/**
|
||||||
|
* ${functionName}Service接口
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @date ${datetime}
|
||||||
|
*/
|
||||||
|
public interface ${ClassName}Service extends IService<${ClassName}> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package ${packageName}.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.javaField == 'createTime' || $column.javaField == 'updateTime')
|
||||||
|
import com.ruoyi.common.core.utils.DateUtils;
|
||||||
|
#break
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import ${packageName}.dao.mysql.${ClassName}Mapper;
|
||||||
|
import ${packageName}.domain.${ClassName};
|
||||||
|
import ${packageName}.service.${ClassName}Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ${functionName}Service业务层处理
|
||||||
|
*
|
||||||
|
* @author ${author}
|
||||||
|
* @date ${datetime}
|
||||||
|
*/
|
||||||
|
@Service("${moduleName}${ClassName}Service")
|
||||||
|
public class ${ClassName}ServiceImpl extends ServiceImpl<${ClassName}Mapper, ${ClassName}> implements ${ClassName}Service {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -16,7 +16,7 @@ import com.ruoyi.common.log.annotation.Log;
|
||||||
import com.ruoyi.common.log.enums.BusinessType;
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
import com.ruoyi.common.security.annotation.PreAuthorize;
|
import com.ruoyi.common.security.annotation.PreAuthorize;
|
||||||
import ${packageName}.domain.${ClassName};
|
import ${packageName}.domain.${ClassName};
|
||||||
import ${packageName}.service.I${ClassName}Service;
|
import ${packageName}.service.${ClassName}Service;
|
||||||
import com.ruoyi.common.core.web.controller.BaseController;
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
import com.ruoyi.common.core.web.domain.AjaxResult;
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||||
|
|
@ -36,7 +36,7 @@ import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
public class ${ClassName}Controller extends BaseController
|
public class ${ClassName}Controller extends BaseController
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private I${ClassName}Service ${className}Service;
|
private ${ClassName}Service ${className}Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询${functionName}列表
|
* 查询${functionName}列表
|
||||||
|
|
|
||||||
|
|
@ -6,23 +6,26 @@ import ${import};
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
import com.ruoyi.common.core.annotation.Excel;
|
import com.ruoyi.common.core.annotation.Excel;
|
||||||
#if($table.crud || $table.sub)
|
#if($table.crud)
|
||||||
import com.ruoyi.common.core.web.domain.BaseEntity;
|
import com.ruoyi.common.core.web.domain.BaseEntity;
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
import com.ruoyi.common.core.web.domain.TreeEntity;
|
import com.ruoyi.common.core.web.domain.TreeEntity;
|
||||||
#end
|
#end
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Builder;
|
||||||
/**
|
/**
|
||||||
* ${functionName}对象 ${tableName}
|
* ${functionName}对象 ${tableName}
|
||||||
*
|
*
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${datetime}
|
* @date ${datetime}
|
||||||
*/
|
*/
|
||||||
#if($table.crud || $table.sub)
|
#if($table.crud)
|
||||||
#set($Entity="BaseEntity")
|
#set($Entity="BaseEntity")
|
||||||
#elseif($table.tree)
|
#elseif($table.tree)
|
||||||
#set($Entity="TreeEntity")
|
#set($Entity="TreeEntity")
|
||||||
#end
|
#end
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
public class ${ClassName} extends ${Entity}
|
public class ${ClassName} extends ${Entity}
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
@ -50,56 +53,4 @@ public class ${ClassName} extends ${Entity}
|
||||||
|
|
||||||
#end
|
#end
|
||||||
#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()
|
|
||||||
{
|
|
||||||
return ${subclassName}List;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void set${subClassName}List(List<${subClassName}> ${subclassName}List)
|
|
||||||
{
|
|
||||||
this.${subclassName}List = ${subclassName}List;
|
|
||||||
}
|
|
||||||
|
|
||||||
#end
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#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
|
|
||||||
.append("${column.javaField}", get${AttrName}())
|
|
||||||
#end
|
|
||||||
#if($table.sub)
|
|
||||||
.append("${subclassName}List", get${subClassName}List())
|
|
||||||
#end
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
@ -9,7 +9,7 @@ import ${packageName}.domain.${ClassName};
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${datetime}
|
* @date ${datetime}
|
||||||
*/
|
*/
|
||||||
public interface I${ClassName}Service
|
public interface ${ClassName}Service
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 查询${functionName}
|
* 查询${functionName}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import ${packageName}.domain.${subClassName};
|
||||||
#end
|
#end
|
||||||
import ${packageName}.mapper.${ClassName}Mapper;
|
import ${packageName}.mapper.${ClassName}Mapper;
|
||||||
import ${packageName}.domain.${ClassName};
|
import ${packageName}.domain.${ClassName};
|
||||||
import ${packageName}.service.I${ClassName}Service;
|
import ${packageName}.service.${ClassName}Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}Service业务层处理
|
* ${functionName}Service业务层处理
|
||||||
|
|
@ -25,8 +25,8 @@ import ${packageName}.service.I${ClassName}Service;
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${datetime}
|
* @date ${datetime}
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service("${moduleName}${ClassName}Service")
|
||||||
public class ${ClassName}ServiceImpl implements I${ClassName}Service
|
public class ${ClassName}ServiceImpl implements ${ClassName}Service
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private ${ClassName}Mapper ${className}Mapper;
|
private ${ClassName}Mapper ${className}Mapper;
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,18 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "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="${packageName}.mapper.${ClassName}Mapper">
|
<mapper namespace="${packageName}.mapper.${ClassName}Mapper">
|
||||||
|
|
||||||
<resultMap type="${ClassName}" id="${ClassName}Result">
|
<resultMap type="${packageName}.domain.${ClassName}" id="${ClassName}Result">
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
<result property="${column.javaField}" column="${column.columnName}" />
|
<result property="${column.javaField}" column="${column.columnName}" />
|
||||||
#end
|
#end
|
||||||
</resultMap>
|
</resultMap>
|
||||||
#if($table.sub)
|
|
||||||
|
|
||||||
<resultMap id="${ClassName}${subClassName}Result" type="${ClassName}" extends="${ClassName}Result">
|
|
||||||
<collection property="${subclassName}List" notNullColumn="${subTable.pkColumn.columnName}" javaType="java.util.List" resultMap="${subClassName}Result" />
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
<resultMap type="${subClassName}" id="${subClassName}Result">
|
|
||||||
#foreach ($column in $subTable.columns)
|
|
||||||
<result property="${column.javaField}" column="${column.columnName}" />
|
|
||||||
#end
|
|
||||||
</resultMap>
|
|
||||||
#end
|
|
||||||
|
|
||||||
<sql id="select${ClassName}Vo">
|
<sql id="select${ClassName}Vo">
|
||||||
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
|
select#foreach($column in $columns) $column.columnName#if($velocityCount != $columns.size()),#end#end from ${tableName}
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="select${ClassName}List" parameterType="${ClassName}" resultMap="${ClassName}Result">
|
<select id="select${ClassName}List" parameterType="${packageName}.domain.${ClassName}" resultMap="${ClassName}Result">
|
||||||
<include refid="select${ClassName}Vo"/>
|
<include refid="select${ClassName}Vo"/>
|
||||||
<where>
|
<where>
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
|
|
@ -58,21 +44,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="#if($table.sub)${ClassName}${subClassName}Result#else${ClassName}Result#end">
|
<select id="select${ClassName}ById" parameterType="${pkColumn.javaType}" resultMap="${ClassName}Result">
|
||||||
#if($table.crud || $table.tree)
|
|
||||||
<include refid="select${ClassName}Vo"/>
|
<include refid="select${ClassName}Vo"/>
|
||||||
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
where ${pkColumn.columnName} = #{${pkColumn.javaField}}
|
||||||
#elseif($table.sub)
|
|
||||||
select#foreach($column in $columns) a.$column.columnName#if($velocityCount != $columns.size()),#end#end,
|
|
||||||
#foreach($column in $subTable.columns) b.$column.columnName#if($velocityCount != $subTable.columns.size()),#end#end
|
|
||||||
|
|
||||||
from ${tableName} a
|
|
||||||
left join ${subTableName} b on b.${subTableFkName} = a.${pkColumn.columnName}
|
|
||||||
where a.${pkColumn.columnName} = #{${pkColumn.javaField}}
|
|
||||||
#end
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insert${ClassName}" parameterType="${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
|
<insert id="insert${ClassName}" parameterType="${packageName}.domain.${ClassName}"#if($pkColumn.increment) useGeneratedKeys="true" keyProperty="$pkColumn.javaField"#end>
|
||||||
insert into ${tableName}
|
insert into ${tableName}
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
|
|
@ -90,7 +67,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="update${ClassName}" parameterType="${ClassName}">
|
<update id="update${ClassName}" parameterType="${packageName}.domain.${ClassName}">
|
||||||
update ${tableName}
|
update ${tableName}
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
#foreach($column in $columns)
|
#foreach($column in $columns)
|
||||||
|
|
@ -112,24 +89,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
#{${pkColumn.javaField}}
|
#{${pkColumn.javaField}}
|
||||||
</foreach>
|
</foreach>
|
||||||
</delete>
|
</delete>
|
||||||
#if($table.sub)
|
|
||||||
|
|
||||||
<delete id="delete${subClassName}By${subTableFkClassName}s" parameterType="String">
|
|
||||||
delete from ${subTableName} where ${subTableFkName} in
|
|
||||||
<foreach item="${subTableFkclassName}" collection="array" open="(" separator="," close=")">
|
|
||||||
#{${subTableFkclassName}}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="delete${subClassName}By${subTableFkClassName}" parameterType="Long">
|
|
||||||
delete from ${subTableName} where ${subTableFkName} = #{${subTableFkclassName}}
|
|
||||||
</delete>
|
|
||||||
|
|
||||||
<insert id="batch${subClassName}">
|
|
||||||
insert into ${subTableName}(#foreach($column in $subTable.columns) $column.columnName#if($velocityCount != $subTable.columns.size()),#end#end) values
|
|
||||||
<foreach item="item" index="index" collection="list" separator=",">
|
|
||||||
(#foreach($column in $subTable.columns) #{item.$column.javaField}#if($velocityCount != $subTable.columns.size()),#end#end)
|
|
||||||
</foreach>
|
|
||||||
</insert>
|
|
||||||
#end
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue