Merge remote-tracking branch 'origin/master'
# Conflicts: # README.md # ruoyi-ui/README.md
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.3.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ruoyi</name>
|
||||
@ -25,7 +25,7 @@
|
||||
<java.version>1.8</java.version>
|
||||
<mybatis.spring.boot.starter.version>1.3.2</mybatis.spring.boot.starter.version>
|
||||
<pagehelper.spring.boot.starter.version>1.2.5</pagehelper.spring.boot.starter.version>
|
||||
<fastjson.version>1.2.68</fastjson.version>
|
||||
<fastjson.version>1.2.70</fastjson.version>
|
||||
<druid.version>1.1.14</druid.version>
|
||||
<commons.io.version>2.5</commons.io.version>
|
||||
<commons.fileupload.version>1.3.3</commons.fileupload.version>
|
||||
|
@ -120,8 +120,8 @@ create table sys_role (
|
||||
-- ----------------------------
|
||||
-- 初始化-角色信息表数据
|
||||
-- ----------------------------
|
||||
insert into sys_role values('1', '管理员', 'admin', 1, 1, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '管理员');
|
||||
insert into sys_role values('2', '普通角色', 'common', 2, 2, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '普通角色');
|
||||
insert into sys_role values('1', '系统管理员', 'admin', 1, 1, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '系统管理员');
|
||||
insert into sys_role values('2', '普通角色', 'common', 2, 2, '0', '0', 'admin', '2018-03-16 11-33-00', 'ry', '2018-03-16 11-33-00', '普通角色');
|
||||
|
||||
|
||||
-- ----------------------------
|
@ -14,7 +14,7 @@ public class RuoYiApplication
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.setProperty("spring.devtools.restart.enabled", "false");
|
||||
// System.setProperty("spring.devtools.restart.enabled", "false");
|
||||
SpringApplication.run(RuoYiApplication.class, args);
|
||||
System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" +
|
||||
" .-------. ____ __ \n" +
|
||||
|
@ -109,6 +109,16 @@ public class Constants
|
||||
*/
|
||||
public static final String JWT_AUTHORITIES = "authorities";
|
||||
|
||||
/**
|
||||
* 参数管理 cache key
|
||||
*/
|
||||
public static final String SYS_CONFIG_KEY = "sys_config:";
|
||||
|
||||
/**
|
||||
* 字典管理 cache key
|
||||
*/
|
||||
public static final String SYS_DICT_KEY = "sys_dict:";
|
||||
|
||||
/**
|
||||
* 资源映射路径 前缀
|
||||
*/
|
||||
|
@ -5,7 +5,7 @@ package com.ruoyi.common.constant;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface HttpStatus
|
||||
public class HttpStatus
|
||||
{
|
||||
/**
|
||||
* 操作成功
|
||||
|
@ -5,7 +5,7 @@ package com.ruoyi.common.constant;
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public interface ScheduleConstants
|
||||
public class ScheduleConstants
|
||||
{
|
||||
public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME";
|
||||
|
||||
|
@ -376,6 +376,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
|
||||
*
|
||||
* @return UUID 的哈希码值。
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
long hilo = mostSigBits ^ leastSigBits;
|
||||
@ -391,6 +392,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
|
||||
*
|
||||
* @return 如果对象相同,则返回 {@code true};否则返回 {@code false}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if ((null == obj) || (obj.getClass() != UUID.class))
|
||||
@ -414,6 +416,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
|
||||
* @return 在此 UUID 小于、等于或大于 val 时,分别返回 -1、0 或 1。
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(UUID val)
|
||||
{
|
||||
// The ordering is intentionally set up so that the UUIDs
|
||||
|
64
ruoyi/src/main/java/com/ruoyi/common/utils/DictUtils.java
Normal file
64
ruoyi/src/main/java/com/ruoyi/common/utils/DictUtils.java
Normal file
@ -0,0 +1,64 @@
|
||||
package com.ruoyi.common.utils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.utils.spring.SpringUtils;
|
||||
import com.ruoyi.framework.redis.RedisCache;
|
||||
import com.ruoyi.project.system.domain.SysDictData;
|
||||
|
||||
/**
|
||||
* 字典工具类
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class DictUtils
|
||||
{
|
||||
/**
|
||||
* 设置字典缓存
|
||||
*
|
||||
* @param key 参数键
|
||||
* @param dictDatas 字典数据列表
|
||||
*/
|
||||
public static void setDictCache(String key, List<SysDictData> dictDatas)
|
||||
{
|
||||
SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典缓存
|
||||
*
|
||||
* @param key 参数键
|
||||
* @return dictDatas 字典数据列表
|
||||
*/
|
||||
public static List<SysDictData> getDictCache(String key)
|
||||
{
|
||||
Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
|
||||
if (StringUtils.isNotNull(cacheObj))
|
||||
{
|
||||
List<SysDictData> DictDatas = StringUtils.cast(cacheObj);
|
||||
return DictDatas;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空字典缓存
|
||||
*/
|
||||
public static void clearDictCache()
|
||||
{
|
||||
Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(Constants.SYS_DICT_KEY + "*");
|
||||
SpringUtils.getBean(RedisCache.class).deleteObject(keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置cache key
|
||||
*
|
||||
* @param configKey 参数键
|
||||
* @return 缓存键key
|
||||
*/
|
||||
public static String getCacheKey(String configKey)
|
||||
{
|
||||
return Constants.SYS_DICT_KEY + configKey;
|
||||
}
|
||||
}
|
@ -450,4 +450,10 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T cast(Object obj)
|
||||
{
|
||||
return (T) obj;
|
||||
}
|
||||
}
|
@ -139,10 +139,12 @@ public class VerifyCodeUtils
|
||||
|
||||
private static Color getRandColor(int fc, int bc)
|
||||
{
|
||||
if (fc > 255)
|
||||
if (fc > 255) {
|
||||
fc = 255;
|
||||
if (bc > 255)
|
||||
}
|
||||
if (bc > 255) {
|
||||
bc = 255;
|
||||
}
|
||||
int r = fc + random.nextInt(bc - fc);
|
||||
int g = fc + random.nextInt(bc - fc);
|
||||
int b = fc + random.nextInt(bc - fc);
|
||||
|
@ -118,7 +118,7 @@ public class HttpUtils
|
||||
StringBuilder result = new StringBuilder();
|
||||
try
|
||||
{
|
||||
String urlNameString = url + "?" + param;
|
||||
String urlNameString = url;
|
||||
log.info("sendPost - {}", urlNameString);
|
||||
URL realUrl = new URL(urlNameString);
|
||||
URLConnection conn = realUrl.openConnection();
|
||||
|
@ -4,6 +4,7 @@ import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.html.EscapeUtil;
|
||||
|
||||
/**
|
||||
* 获取IP方法
|
||||
@ -40,8 +41,7 @@ public class IpUtils
|
||||
{
|
||||
ip = request.getRemoteAddr();
|
||||
}
|
||||
|
||||
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : ip;
|
||||
return "0:0:0:0:0:0:0:1".equals(ip) ? "127.0.0.1" : EscapeUtil.clean(ip);
|
||||
}
|
||||
|
||||
public static boolean internalIp(String ip)
|
||||
@ -110,8 +110,9 @@ public class IpUtils
|
||||
{
|
||||
case 1:
|
||||
l = Long.parseLong(elements[0]);
|
||||
if ((l < 0L) || (l > 4294967295L))
|
||||
if ((l < 0L) || (l > 4294967295L)) {
|
||||
return null;
|
||||
}
|
||||
bytes[0] = (byte) (int) (l >> 24 & 0xFF);
|
||||
bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
|
||||
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
|
||||
@ -119,12 +120,14 @@ public class IpUtils
|
||||
break;
|
||||
case 2:
|
||||
l = Integer.parseInt(elements[0]);
|
||||
if ((l < 0L) || (l > 255L))
|
||||
if ((l < 0L) || (l > 255L)) {
|
||||
return null;
|
||||
}
|
||||
bytes[0] = (byte) (int) (l & 0xFF);
|
||||
l = Integer.parseInt(elements[1]);
|
||||
if ((l < 0L) || (l > 16777215L))
|
||||
if ((l < 0L) || (l > 16777215L)) {
|
||||
return null;
|
||||
}
|
||||
bytes[1] = (byte) (int) (l >> 16 & 0xFF);
|
||||
bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
|
||||
bytes[3] = (byte) (int) (l & 0xFF);
|
||||
@ -133,13 +136,15 @@ public class IpUtils
|
||||
for (i = 0; i < 2; ++i)
|
||||
{
|
||||
l = Integer.parseInt(elements[i]);
|
||||
if ((l < 0L) || (l > 255L))
|
||||
if ((l < 0L) || (l > 255L)) {
|
||||
return null;
|
||||
}
|
||||
bytes[i] = (byte) (int) (l & 0xFF);
|
||||
}
|
||||
l = Integer.parseInt(elements[2]);
|
||||
if ((l < 0L) || (l > 65535L))
|
||||
if ((l < 0L) || (l > 65535L)) {
|
||||
return null;
|
||||
}
|
||||
bytes[2] = (byte) (int) (l >> 8 & 0xFF);
|
||||
bytes[3] = (byte) (int) (l & 0xFF);
|
||||
break;
|
||||
@ -147,8 +152,9 @@ public class IpUtils
|
||||
for (i = 0; i < 4; ++i)
|
||||
{
|
||||
l = Integer.parseInt(elements[i]);
|
||||
if ((l < 0L) || (l > 255L))
|
||||
if ((l < 0L) || (l > 255L)) {
|
||||
return null;
|
||||
}
|
||||
bytes[i] = (byte) (int) (l & 0xFF);
|
||||
}
|
||||
break;
|
||||
|
@ -52,6 +52,11 @@ public class DataScopeAspect
|
||||
*/
|
||||
public static final String DATA_SCOPE_SELF = "5";
|
||||
|
||||
/**
|
||||
* 数据权限过滤关键字
|
||||
*/
|
||||
public static final String DATA_SCOPE = "dataScope";
|
||||
|
||||
// 配置织入点
|
||||
@Pointcut("@annotation(com.ruoyi.framework.aspectj.lang.annotation.DataScope)")
|
||||
public void dataScopePointCut()
|
||||
@ -138,7 +143,7 @@ public class DataScopeAspect
|
||||
if (StringUtils.isNotBlank(sqlString.toString()))
|
||||
{
|
||||
BaseEntity baseEntity = (BaseEntity) joinPoint.getArgs()[0];
|
||||
baseEntity.setDataScope(" AND (" + sqlString.substring(4) + ")");
|
||||
baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] serialize(T t) throws SerializationException
|
||||
{
|
||||
if (t == null)
|
||||
@ -45,6 +46,7 @@ public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
|
||||
return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T deserialize(byte[] bytes) throws SerializationException
|
||||
{
|
||||
if (bytes == null || bytes.length <= 0)
|
||||
|
@ -36,9 +36,6 @@ public class BaseEntity implements Serializable
|
||||
/** 备注 */
|
||||
private String remark;
|
||||
|
||||
/** 数据权限 */
|
||||
private String dataScope;
|
||||
|
||||
/** 开始时间 */
|
||||
@JsonIgnore
|
||||
private String beginTime;
|
||||
@ -110,16 +107,6 @@ public class BaseEntity implements Serializable
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getDataScope()
|
||||
{
|
||||
return dataScope;
|
||||
}
|
||||
|
||||
public void setDataScope(String dataScope)
|
||||
{
|
||||
this.dataScope = dataScope;
|
||||
}
|
||||
|
||||
public String getBeginTime()
|
||||
{
|
||||
return beginTime;
|
||||
|
@ -47,6 +47,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService
|
||||
* @param operIds 需要删除的操作日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteOperLogByIds(Long[] operIds)
|
||||
{
|
||||
return operLogMapper.deleteOperLogByIds(operIds);
|
||||
|
@ -118,4 +118,16 @@ public class SysConfigController extends BaseController
|
||||
{
|
||||
return toAjax(configService.deleteConfigByIds(configIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空缓存
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:config:remove')")
|
||||
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/clearCache")
|
||||
public AjaxResult clearCache()
|
||||
{
|
||||
configService.clearCache();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import com.ruoyi.framework.web.domain.AjaxResult;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
import com.ruoyi.project.system.domain.SysDictData;
|
||||
import com.ruoyi.project.system.service.ISysDictDataService;
|
||||
import com.ruoyi.project.system.service.ISysDictTypeService;
|
||||
|
||||
/**
|
||||
* 数据字典信息
|
||||
@ -34,6 +35,9 @@ public class SysDictDataController extends BaseController
|
||||
@Autowired
|
||||
private ISysDictDataService dictDataService;
|
||||
|
||||
@Autowired
|
||||
private ISysDictTypeService dictTypeService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysDictData dictData)
|
||||
@ -66,10 +70,10 @@ public class SysDictDataController extends BaseController
|
||||
/**
|
||||
* 根据字典类型查询字典数据信息
|
||||
*/
|
||||
@GetMapping(value = "/dictType/{dictType}")
|
||||
@GetMapping(value = "/type/{dictType}")
|
||||
public AjaxResult dictType(@PathVariable String dictType)
|
||||
{
|
||||
return AjaxResult.success(dictDataService.selectDictDataByType(dictType));
|
||||
return AjaxResult.success(dictTypeService.selectDictDataByType(dictType));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,6 +107,18 @@ public class SysDictTypeController extends BaseController
|
||||
return toAjax(dictTypeService.deleteDictTypeByIds(dictIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空缓存
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
|
||||
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/clearCache")
|
||||
public AjaxResult clearCache()
|
||||
{
|
||||
dictTypeService.clearCache();
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典选择框列表
|
||||
*/
|
||||
|
@ -42,10 +42,7 @@ public class SysLoginController
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param password 密码
|
||||
* @param captcha 验证码
|
||||
* @param uuid 唯一标识
|
||||
* @param loginBody 登陆信息
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/login")
|
||||
|
@ -48,7 +48,7 @@ public class SysPostController extends BaseController
|
||||
}
|
||||
|
||||
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
|
||||
@PreAuthorize("@ss.hasPermi('system:config:export')")
|
||||
@PreAuthorize("@ss.hasPermi('system:post:export')")
|
||||
@GetMapping("/export")
|
||||
public AjaxResult export(SysPost post)
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.ruoyi.project.system.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -25,6 +26,7 @@ import com.ruoyi.framework.security.service.TokenService;
|
||||
import com.ruoyi.framework.web.controller.BaseController;
|
||||
import com.ruoyi.framework.web.domain.AjaxResult;
|
||||
import com.ruoyi.framework.web.page.TableDataInfo;
|
||||
import com.ruoyi.project.system.domain.SysRole;
|
||||
import com.ruoyi.project.system.domain.SysUser;
|
||||
import com.ruoyi.project.system.service.ISysPostService;
|
||||
import com.ruoyi.project.system.service.ISysRoleService;
|
||||
@ -101,7 +103,8 @@ public class SysUserController extends BaseController
|
||||
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put("roles", roleService.selectRoleAll());
|
||||
List<SysRole> roles = roleService.selectRoleAll();
|
||||
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
ajax.put("posts", postService.selectPostAll());
|
||||
if (StringUtils.isNotNull(userId))
|
||||
{
|
||||
|
@ -178,6 +178,7 @@ public class SysRole extends BaseEntity
|
||||
this.deptIds = deptIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("roleId", getRoleId())
|
||||
|
@ -50,14 +50,6 @@ public interface ISysConfigService
|
||||
*/
|
||||
public int updateConfig(SysConfig config);
|
||||
|
||||
/**
|
||||
* 删除参数配置信息
|
||||
*
|
||||
* @param configId 参数ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteConfigById(Long configId);
|
||||
|
||||
/**
|
||||
* 批量删除参数信息
|
||||
*
|
||||
@ -66,6 +58,11 @@ public interface ISysConfigService
|
||||
*/
|
||||
public int deleteConfigByIds(Long[] configIds);
|
||||
|
||||
/**
|
||||
* 清空缓存数据
|
||||
*/
|
||||
public void clearCache();
|
||||
|
||||
/**
|
||||
* 校验参数键名是否唯一
|
||||
*
|
||||
|
@ -18,14 +18,6 @@ public interface ISysDictDataService
|
||||
*/
|
||||
public List<SysDictData> selectDictDataList(SysDictData dictData);
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
public List<SysDictData> selectDictDataByType(String dictType);
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典键值查询字典数据信息
|
||||
*
|
||||
@ -43,14 +35,6 @@ public interface ISysDictDataService
|
||||
*/
|
||||
public SysDictData selectDictDataById(Long dictCode);
|
||||
|
||||
/**
|
||||
* 通过字典ID删除字典数据信息
|
||||
*
|
||||
* @param dictCode 字典数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDictDataById(Long dictCode);
|
||||
|
||||
/**
|
||||
* 批量删除字典数据信息
|
||||
*
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.ruoyi.project.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.project.system.domain.SysDictData;
|
||||
import com.ruoyi.project.system.domain.SysDictType;
|
||||
|
||||
/**
|
||||
@ -25,6 +26,14 @@ public interface ISysDictTypeService
|
||||
*/
|
||||
public List<SysDictType> selectDictTypeAll();
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
public List<SysDictData> selectDictDataByType(String dictType);
|
||||
|
||||
/**
|
||||
* 根据字典类型ID查询信息
|
||||
*
|
||||
@ -41,14 +50,6 @@ public interface ISysDictTypeService
|
||||
*/
|
||||
public SysDictType selectDictTypeByType(String dictType);
|
||||
|
||||
/**
|
||||
* 通过字典ID删除字典信息
|
||||
*
|
||||
* @param dictId 字典ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteDictTypeById(Long dictId);
|
||||
|
||||
/**
|
||||
* 批量删除字典信息
|
||||
*
|
||||
@ -57,6 +58,11 @@ public interface ISysDictTypeService
|
||||
*/
|
||||
public int deleteDictTypeByIds(Long[] dictIds);
|
||||
|
||||
/**
|
||||
* 清空缓存数据
|
||||
*/
|
||||
public void clearCache();
|
||||
|
||||
/**
|
||||
* 新增保存字典类型信息
|
||||
*
|
||||
|
@ -1,10 +1,15 @@
|
||||
package com.ruoyi.project.system.service.impl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import javax.annotation.PostConstruct;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.redis.RedisCache;
|
||||
import com.ruoyi.project.system.domain.SysConfig;
|
||||
import com.ruoyi.project.system.mapper.SysConfigMapper;
|
||||
import com.ruoyi.project.system.service.ISysConfigService;
|
||||
@ -20,6 +25,22 @@ public class SysConfigServiceImpl implements ISysConfigService
|
||||
@Autowired
|
||||
private SysConfigMapper configMapper;
|
||||
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* 项目启动时,初始化参数到缓存
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init()
|
||||
{
|
||||
List<SysConfig> configsList = configMapper.selectConfigList(new SysConfig());
|
||||
for (SysConfig config : configsList)
|
||||
{
|
||||
redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询参数配置信息
|
||||
*
|
||||
@ -43,10 +64,20 @@ public class SysConfigServiceImpl implements ISysConfigService
|
||||
@Override
|
||||
public String selectConfigByKey(String configKey)
|
||||
{
|
||||
String configValue = Convert.toStr(redisCache.getCacheObject(getCacheKey(configKey)));
|
||||
if (StringUtils.isNotEmpty(configValue))
|
||||
{
|
||||
return configValue;
|
||||
}
|
||||
SysConfig config = new SysConfig();
|
||||
config.setConfigKey(configKey);
|
||||
SysConfig retConfig = configMapper.selectConfig(config);
|
||||
return StringUtils.isNotNull(retConfig) ? retConfig.getConfigValue() : "";
|
||||
if (StringUtils.isNotNull(retConfig))
|
||||
{
|
||||
redisCache.setCacheObject(getCacheKey(configKey), retConfig.getConfigValue());
|
||||
return retConfig.getConfigValue();
|
||||
}
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,7 +101,12 @@ public class SysConfigServiceImpl implements ISysConfigService
|
||||
@Override
|
||||
public int insertConfig(SysConfig config)
|
||||
{
|
||||
return configMapper.insertConfig(config);
|
||||
int row = configMapper.insertConfig(config);
|
||||
if (row > 0)
|
||||
{
|
||||
redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,19 +118,12 @@ public class SysConfigServiceImpl implements ISysConfigService
|
||||
@Override
|
||||
public int updateConfig(SysConfig config)
|
||||
{
|
||||
return configMapper.updateConfig(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除参数配置信息
|
||||
*
|
||||
* @param configId 参数ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteConfigById(Long configId)
|
||||
{
|
||||
return configMapper.deleteConfigById(configId);
|
||||
int row = configMapper.updateConfig(config);
|
||||
if (row > 0)
|
||||
{
|
||||
redisCache.setCacheObject(getCacheKey(config.getConfigKey()), config.getConfigValue());
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,7 +135,23 @@ public class SysConfigServiceImpl implements ISysConfigService
|
||||
@Override
|
||||
public int deleteConfigByIds(Long[] configIds)
|
||||
{
|
||||
return configMapper.deleteConfigByIds(configIds);
|
||||
int count = configMapper.deleteConfigByIds(configIds);
|
||||
if (count > 0)
|
||||
{
|
||||
Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
|
||||
redisCache.deleteObject(keys);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空缓存数据
|
||||
*/
|
||||
@Override
|
||||
public void clearCache()
|
||||
{
|
||||
Collection<String> keys = redisCache.keys(Constants.SYS_CONFIG_KEY + "*");
|
||||
redisCache.deleteObject(keys);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,4 +171,15 @@ public class SysConfigServiceImpl implements ISysConfigService
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置cache key
|
||||
*
|
||||
* @param configKey 参数键
|
||||
* @return 缓存键key
|
||||
*/
|
||||
private String getCacheKey(String configKey)
|
||||
{
|
||||
return Constants.SYS_CONFIG_KEY + configKey;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.ruoyi.project.system.service.impl;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.common.utils.DictUtils;
|
||||
import com.ruoyi.project.system.domain.SysDictData;
|
||||
import com.ruoyi.project.system.mapper.SysDictDataMapper;
|
||||
import com.ruoyi.project.system.service.ISysDictDataService;
|
||||
@ -30,18 +31,6 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
||||
return dictDataMapper.selectDictDataList(dictData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysDictData> selectDictDataByType(String dictType)
|
||||
{
|
||||
return dictDataMapper.selectDictDataByType(dictType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型和字典键值查询字典数据信息
|
||||
*
|
||||
@ -67,27 +56,21 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
||||
return dictDataMapper.selectDictDataById(dictCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过字典ID删除字典数据信息
|
||||
*
|
||||
* @param dictCode 字典数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDictDataById(Long dictCode)
|
||||
{
|
||||
return dictDataMapper.deleteDictDataById(dictCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除字典数据信息
|
||||
*
|
||||
* @param dictCodes 需要删除的字典数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDictDataByIds(Long[] dictCodes)
|
||||
{
|
||||
return dictDataMapper.deleteDictDataByIds(dictCodes);
|
||||
int row = dictDataMapper.deleteDictDataByIds(dictCodes);
|
||||
if (row > 0)
|
||||
{
|
||||
DictUtils.clearDictCache();
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,7 +82,12 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
||||
@Override
|
||||
public int insertDictData(SysDictData dictData)
|
||||
{
|
||||
return dictDataMapper.insertDictData(dictData);
|
||||
int row = dictDataMapper.insertDictData(dictData);
|
||||
if (row > 0)
|
||||
{
|
||||
DictUtils.clearDictCache();
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -111,6 +99,11 @@ public class SysDictDataServiceImpl implements ISysDictDataService
|
||||
@Override
|
||||
public int updateDictData(SysDictData dictData)
|
||||
{
|
||||
return dictDataMapper.updateDictData(dictData);
|
||||
int row = dictDataMapper.updateDictData(dictData);
|
||||
if (row > 0)
|
||||
{
|
||||
DictUtils.clearDictCache();
|
||||
}
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,15 @@
|
||||
package com.ruoyi.project.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import javax.annotation.PostConstruct;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.exception.CustomException;
|
||||
import com.ruoyi.common.utils.DictUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.project.system.domain.SysDictData;
|
||||
import com.ruoyi.project.system.domain.SysDictType;
|
||||
import com.ruoyi.project.system.mapper.SysDictDataMapper;
|
||||
import com.ruoyi.project.system.mapper.SysDictTypeMapper;
|
||||
@ -25,6 +29,20 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
@Autowired
|
||||
private SysDictDataMapper dictDataMapper;
|
||||
|
||||
/**
|
||||
* 项目启动时,初始化字典到缓存
|
||||
*/
|
||||
@PostConstruct
|
||||
public void init()
|
||||
{
|
||||
List<SysDictType> dictTypeList = dictTypeMapper.selectDictTypeAll();
|
||||
for (SysDictType dictType : dictTypeList)
|
||||
{
|
||||
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType.getDictType());
|
||||
DictUtils.setDictCache(dictType.getDictType(), dictDatas);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询字典类型
|
||||
*
|
||||
@ -48,6 +66,29 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
return dictTypeMapper.selectDictTypeAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型查询字典数据
|
||||
*
|
||||
* @param dictType 字典类型
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysDictData> selectDictDataByType(String dictType)
|
||||
{
|
||||
List<SysDictData> dictDatas = DictUtils.getDictCache(dictType);
|
||||
if (StringUtils.isNotNull(dictDatas))
|
||||
{
|
||||
return dictDatas;
|
||||
}
|
||||
dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
||||
if (StringUtils.isNotNull(dictDatas))
|
||||
{
|
||||
DictUtils.setDictCache(dictType, dictDatas);
|
||||
return dictDatas;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典类型ID查询信息
|
||||
*
|
||||
@ -66,32 +107,44 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
* @param dictType 字典类型
|
||||
* @return 字典类型
|
||||
*/
|
||||
@Override
|
||||
public SysDictType selectDictTypeByType(String dictType)
|
||||
{
|
||||
return dictTypeMapper.selectDictTypeByType(dictType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过字典ID删除字典信息
|
||||
*
|
||||
* @param dictId 字典ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDictTypeById(Long dictId)
|
||||
{
|
||||
return dictTypeMapper.deleteDictTypeById(dictId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除字典类型信息
|
||||
*
|
||||
* @param dictIds 需要删除的字典ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteDictTypeByIds(Long[] dictIds)
|
||||
{
|
||||
return dictTypeMapper.deleteDictTypeByIds(dictIds);
|
||||
for (Long dictId : dictIds)
|
||||
{
|
||||
SysDictType dictType = selectDictTypeById(dictId);
|
||||
if (dictDataMapper.countDictDataByType(dictType.getDictType()) > 0)
|
||||
{
|
||||
throw new CustomException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
|
||||
}
|
||||
}
|
||||
int count = dictTypeMapper.deleteDictTypeByIds(dictIds);
|
||||
if (count > 0)
|
||||
{
|
||||
DictUtils.clearDictCache();
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空缓存数据
|
||||
*/
|
||||
@Override
|
||||
public void clearCache()
|
||||
{
|
||||
DictUtils.clearDictCache();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,7 +156,12 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
@Override
|
||||
public int insertDictType(SysDictType dictType)
|
||||
{
|
||||
return dictTypeMapper.insertDictType(dictType);
|
||||
int row = dictTypeMapper.insertDictType(dictType);
|
||||
if (row > 0)
|
||||
{
|
||||
DictUtils.clearDictCache();
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -118,7 +176,12 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
||||
{
|
||||
SysDictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId());
|
||||
dictDataMapper.updateDictDataType(oldDict.getDictType(), dictType.getDictType());
|
||||
return dictTypeMapper.updateDictType(dictType);
|
||||
int row = dictTypeMapper.updateDictType(dictType);
|
||||
if (row > 0)
|
||||
{
|
||||
DictUtils.clearDictCache();
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,6 +121,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
* @param roleId 角色ID
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
@Override
|
||||
public List<Integer> selectMenuListByRoleId(Long roleId)
|
||||
{
|
||||
return menuMapper.selectMenuListByRoleId(roleId);
|
||||
@ -140,7 +141,7 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
{
|
||||
RouterVo router = new RouterVo();
|
||||
router.setHidden("1".equals(menu.getVisible()));
|
||||
router.setName(StringUtils.capitalize(menu.getPath()));
|
||||
router.setName(getRouteName(menu));
|
||||
router.setPath(getRouterPath(menu));
|
||||
router.setComponent(getComponent(menu));
|
||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
||||
@ -299,6 +300,23 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由名称
|
||||
*
|
||||
* @param menu 菜单信息
|
||||
* @return 路由名称
|
||||
*/
|
||||
public String getRouteName(SysMenu menu)
|
||||
{
|
||||
String routerName = StringUtils.capitalize(menu.getPath());
|
||||
// 非外链并且是一级目录(类型为目录)
|
||||
if (isMeunFrame(menu))
|
||||
{
|
||||
routerName = StringUtils.EMPTY;
|
||||
}
|
||||
return routerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取路由地址
|
||||
*
|
||||
|
@ -84,6 +84,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService
|
||||
* @param noticeIds 需要删除的公告ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteNoticeByIds(Long[] noticeIds)
|
||||
{
|
||||
return noticeMapper.deleteNoticeByIds(noticeIds);
|
||||
|
@ -66,6 +66,7 @@ public class SysPostServiceImpl implements ISysPostService
|
||||
* @param userId 用户ID
|
||||
* @return 选中岗位ID列表
|
||||
*/
|
||||
@Override
|
||||
public List<Integer> selectPostListByUserId(Long userId)
|
||||
{
|
||||
return postMapper.selectPostListByUserId(userId);
|
||||
@ -138,6 +139,7 @@ public class SysPostServiceImpl implements ISysPostService
|
||||
* @return 结果
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
@Override
|
||||
public int deletePostByIds(Long[] postIds)
|
||||
{
|
||||
for (Long postId : postIds)
|
||||
|
@ -81,6 +81,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
*
|
||||
* @return 角色列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysRole> selectRoleAll()
|
||||
{
|
||||
return SpringUtils.getAopProxy(this).selectRoleList(new SysRole());
|
||||
@ -92,6 +93,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
* @param userId 用户ID
|
||||
* @return 选中角色ID列表
|
||||
*/
|
||||
@Override
|
||||
public List<Integer> selectRoleListByUserId(Long userId)
|
||||
{
|
||||
return roleMapper.selectRoleListByUserId(userId);
|
||||
@ -103,6 +105,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
* @param roleId 角色ID
|
||||
* @return 角色对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysRole selectRoleById(Long roleId)
|
||||
{
|
||||
return roleMapper.selectRoleById(roleId);
|
||||
@ -149,6 +152,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
*
|
||||
* @param role 角色信息
|
||||
*/
|
||||
@Override
|
||||
public void checkRoleAllowed(SysRole role)
|
||||
{
|
||||
if (StringUtils.isNotNull(role.getRoleId()) && role.isAdmin())
|
||||
@ -207,6 +211,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
* @param role 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateRoleStatus(SysRole role)
|
||||
{
|
||||
return roleMapper.updateRole(role);
|
||||
@ -296,6 +301,7 @@ public class SysRoleServiceImpl implements ISysRoleService
|
||||
* @param roleIds 需要删除的角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteRoleByIds(Long[] roleIds)
|
||||
{
|
||||
for (Long roleId : roleIds)
|
||||
|
@ -72,6 +72,7 @@ public class SysUserOnlineServiceImpl implements ISysUserOnlineService
|
||||
* @param user 用户信息
|
||||
* @return 在线用户
|
||||
*/
|
||||
@Override
|
||||
public SysUserOnline loginUserToUserOnline(LoginUser user)
|
||||
{
|
||||
if (StringUtils.isNull(user) && StringUtils.isNull(user.getUser()))
|
||||
|
@ -192,6 +192,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
*
|
||||
* @param user 用户信息
|
||||
*/
|
||||
@Override
|
||||
public void checkUserAllowed(SysUser user)
|
||||
{
|
||||
if (StringUtils.isNotNull(user.getUserId()) && user.isAdmin())
|
||||
@ -268,10 +269,11 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
/**
|
||||
* 修改用户头像
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param userName 用户名
|
||||
* @param avatar 头像地址
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean updateUserAvatar(String userName, String avatar)
|
||||
{
|
||||
return userMapper.updateUserAvatar(userName, avatar) > 0;
|
||||
@ -376,6 +378,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||
* @param userIds 需要删除的用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteUserByIds(Long[] userIds)
|
||||
{
|
||||
for (Long userId : userIds)
|
||||
|
@ -21,7 +21,7 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService
|
||||
/**
|
||||
* 查询业务字段列表
|
||||
*
|
||||
* @param genTableColumn 业务字段编号
|
||||
* @param tableId 业务字段编号
|
||||
* @return 业务字段集合
|
||||
*/
|
||||
@Override
|
||||
|
@ -80,6 +80,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
* @param genTable 业务信息
|
||||
* @return 数据库表集合
|
||||
*/
|
||||
@Override
|
||||
public List<GenTable> selectDbTableList(GenTable genTable)
|
||||
{
|
||||
return genTableMapper.selectDbTableList(genTable);
|
||||
@ -91,6 +92,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
* @param tableNames 表名称组
|
||||
* @return 数据库表集合
|
||||
*/
|
||||
@Override
|
||||
public List<GenTable> selectDbTableListByNames(String[] tableNames)
|
||||
{
|
||||
return genTableMapper.selectDbTableListByNames(tableNames);
|
||||
@ -121,7 +123,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
/**
|
||||
* 删除业务对象
|
||||
*
|
||||
* @param ids 需要删除的数据ID
|
||||
* @param tableIds 需要删除的数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@ -142,9 +144,9 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
public void importGenTable(List<GenTable> tableList)
|
||||
{
|
||||
String operName = SecurityUtils.getUsername();
|
||||
for (GenTable table : tableList)
|
||||
try
|
||||
{
|
||||
try
|
||||
for (GenTable table : tableList)
|
||||
{
|
||||
String tableName = table.getTableName();
|
||||
GenUtils.initTable(table, operName);
|
||||
@ -160,10 +162,10 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
log.error("表名 " + table.getTableName() + " 导入失败:", e);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new CustomException("导入失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -173,6 +175,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
* @param tableId 表编号
|
||||
* @return 预览数据列表
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> previewCode(Long tableId)
|
||||
{
|
||||
Map<String, String> dataMap = new LinkedHashMap<>();
|
||||
@ -277,6 +280,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
*
|
||||
* @param genTable 业务信息
|
||||
*/
|
||||
@Override
|
||||
public void validateEdit(GenTable genTable)
|
||||
{
|
||||
if (GenConstants.TPL_TREE.equals(genTable.getTplCategory()))
|
||||
@ -301,7 +305,7 @@ public class GenTableServiceImpl implements IGenTableService
|
||||
/**
|
||||
* 设置主键列信息
|
||||
*
|
||||
* @param genTable 业务表信息
|
||||
* @param table 业务表信息
|
||||
* @param columns 业务字段列表
|
||||
*/
|
||||
public void setPkColumn(GenTable table, List<GenTableColumn> columns)
|
||||
|
@ -13,7 +13,7 @@ public interface IGenTableColumnService
|
||||
/**
|
||||
* 查询业务字段列表
|
||||
*
|
||||
* @param genTableColumn 业务字段编号
|
||||
* @param tableId 业务字段编号
|
||||
* @return 业务字段集合
|
||||
*/
|
||||
public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId);
|
||||
|
@ -58,11 +58,11 @@ public class GenUtils
|
||||
{
|
||||
column.setHtmlType(GenConstants.HTML_INPUT);
|
||||
|
||||
// 如果是浮点型
|
||||
// 如果是浮点型 统一用BigDecimal
|
||||
String[] str = StringUtils.split(StringUtils.substringBetween(column.getColumnType(), "(", ")"), ",");
|
||||
if (str != null && str.length == 2 && Integer.parseInt(str[1]) > 0)
|
||||
{
|
||||
column.setJavaType(GenConstants.TYPE_DOUBLE);
|
||||
column.setJavaType(GenConstants.TYPE_BIGDECIMAL);
|
||||
}
|
||||
// 如果是整形
|
||||
else if (str != null && str.length == 1 && Integer.parseInt(str[0]) <= 10)
|
||||
|
@ -0,0 +1 @@
|
||||
restart.include.json=/com.alibaba.fastjson.*.jar
|
@ -3,7 +3,7 @@ ruoyi:
|
||||
# 名称
|
||||
name: RuoYi
|
||||
# 版本
|
||||
version: 2.2.0
|
||||
version: 2.3.0
|
||||
# 版权年份
|
||||
copyrightYear: 2019
|
||||
# 实例演示开关
|
||||
@ -79,7 +79,7 @@ spring:
|
||||
token:
|
||||
# 令牌自定义标识
|
||||
header: Authorization
|
||||
# 令牌秘钥
|
||||
# 令牌密钥
|
||||
secret: abcdefghijklmnopqrstuvwxyz
|
||||
# 令牌有效期(默认30分钟)
|
||||
expireTime: 30
|
||||
|
@ -40,7 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${dataScope}
|
||||
${params.dataScope}
|
||||
order by d.parent_id, d.order_num
|
||||
</select>
|
||||
|
||||
|
@ -38,6 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
order by dict_sort asc
|
||||
</select>
|
||||
|
||||
<select id="selectDictDataByType" parameterType="SysDictData" resultMap="SysDictDataResult">
|
||||
@ -73,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="updateDictData" parameterType="SysDictData">
|
||||
update sys_dict_data
|
||||
<set>
|
||||
<if test="dictSort != null and dictSort != ''">dict_sort = #{dictSort},</if>
|
||||
<if test="dictSort != null">dict_sort = #{dictSort},</if>
|
||||
<if test="dictLabel != null and dictLabel != ''">dict_label = #{dictLabel},</if>
|
||||
<if test="dictValue != null and dictValue != ''">dict_value = #{dictValue},</if>
|
||||
<if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
|
||||
@ -94,7 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<insert id="insertDictData" parameterType="SysDictData">
|
||||
insert into sys_dict_data(
|
||||
<if test="dictSort != null and dictSort != ''">dict_sort,</if>
|
||||
<if test="dictSort != null">dict_sort,</if>
|
||||
<if test="dictLabel != null and dictLabel != ''">dict_label,</if>
|
||||
<if test="dictValue != null and dictValue != ''">dict_value,</if>
|
||||
<if test="dictType != null and dictType != ''">dict_type,</if>
|
||||
@ -106,7 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="dictSort != null and dictSort != ''">#{dictSort},</if>
|
||||
<if test="dictSort != null">#{dictSort},</if>
|
||||
<if test="dictLabel != null and dictLabel != ''">#{dictLabel},</if>
|
||||
<if test="dictValue != null and dictValue != ''">#{dictValue},</if>
|
||||
<if test="dictType != null and dictType != ''">#{dictType},</if>
|
||||
|
@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and date_format(r.create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${dataScope}
|
||||
${params.dataScope}
|
||||
order by r.role_sort
|
||||
</select>
|
||||
|
||||
|
@ -78,7 +78,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND (u.dept_id = #{deptId} OR u.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE FIND_IN_SET (#{deptId},ancestors) ))
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${dataScope}
|
||||
${params.dataScope}
|
||||
</select>
|
||||
|
||||
<select id="selectUserByUserName" parameterType="String" resultMap="SysUserResult">
|
||||
|
@ -6,17 +6,17 @@ values('${functionName}', '3', '1', '${businessName}', '${moduleName}/${business
|
||||
SELECT @parentId := LAST_INSERT_ID();
|
||||
|
||||
-- 按钮 SQL
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}查询', @parentId, '1', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:query', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}新增', @parentId, '2', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}修改', @parentId, '3', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}删除', @parentId, '4', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
|
||||
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
|
||||
values('${functionName}导出', @parentId, '5', '#', '', 1, 'F', '0', '0', '${permissionPrefix}:export', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
|
@ -146,7 +146,7 @@
|
||||
v-for="dict in ${field}Options"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
#if($column.javaType == "Integer"):value="parseInt(dict.dictValue)"#else:value="dict.dictValue"#end
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.dictValue)"#else:value="dict.dictValue"#end
|
||||
|
||||
></el-option>
|
||||
</el-select>
|
||||
@ -163,7 +163,7 @@
|
||||
<el-radio
|
||||
v-for="dict in ${field}Options"
|
||||
:key="dict.dictValue"
|
||||
#if($column.javaType == "Integer"):label="parseInt(dict.dictValue)"#else:label="dict.dictValue"#end
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.dictValue)"#else:label="dict.dictValue"#end
|
||||
|
||||
>{{dict.dictLabel}}</el-radio>
|
||||
</el-radio-group>
|
||||
@ -375,8 +375,6 @@ export default {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -385,8 +383,6 @@ export default {
|
||||
this.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -174,7 +174,7 @@
|
||||
v-for="dict in ${field}Options"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
#if($column.javaType == "Integer"):value="parseInt(dict.dictValue)"#else:value="dict.dictValue"#end
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long"):value="parseInt(dict.dictValue)"#else:value="dict.dictValue"#end
|
||||
|
||||
></el-option>
|
||||
</el-select>
|
||||
@ -191,7 +191,7 @@
|
||||
<el-radio
|
||||
v-for="dict in ${field}Options"
|
||||
:key="dict.dictValue"
|
||||
#if($column.javaType == "Integer"):label="parseInt(dict.dictValue)"#else:label="dict.dictValue"#end
|
||||
#if($column.javaType == "Integer" || $column.javaType == "Long"):label="parseInt(dict.dictValue)"#else:label="dict.dictValue"#end
|
||||
|
||||
>{{dict.dictLabel}}</el-radio>
|
||||
</el-radio-group>
|
||||
@ -392,8 +392,6 @@ export default {
|
||||
this.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@ -402,8 +400,6 @@ export default {
|
||||
this.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -56,14 +56,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
|
||||
<if test="$column.javaField != null #if($column.javaType == 'String' ) and $column.javaField != ''#end">$column.columnName,</if>
|
||||
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName,</if>
|
||||
#end
|
||||
#end
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pkColumn.columnName || !$pkColumn.increment)
|
||||
<if test="$column.javaField != null #if($column.javaType == 'String' ) and $column.javaField != ''#end">#{$column.javaField},</if>
|
||||
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">#{$column.javaField},</if>
|
||||
#end
|
||||
#end
|
||||
</trim>
|
||||
@ -74,7 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
#foreach($column in $columns)
|
||||
#if($column.columnName != $pkColumn.columnName)
|
||||
<if test="$column.javaField != null #if($column.javaType == 'String' ) and $column.javaField != ''#end">$column.columnName = #{$column.javaField},</if>
|
||||
<if test="$column.javaField != null#if($column.javaType == 'String' && $column.required) and $column.javaField != ''#end">$column.columnName = #{$column.javaField},</if>
|
||||
#end
|
||||
#end
|
||||
</trim>
|
||||
|
Reference in New Issue
Block a user