添加抽屉表单模板.
This commit is contained in:
@@ -63,6 +63,8 @@ new GenTable("system_role", "角色", "role")
|
||||
.ignoreTest()
|
||||
// 生成 vue 文件, 一级业务包为 user, 二级业务包为 role (前端命名只能使用脊柱命名法)
|
||||
.vue("user", "role")
|
||||
// 前端使用抽屉表单
|
||||
.useDrawerForm()
|
||||
// 前端代码生成的枚举对象 可变参数
|
||||
.enums(RoleStatusEnum.class);
|
||||
```
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.orion.ops.framework.redis.core.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.orion.lang.define.cache.CacheKeyDefine;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* redis list 工具类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/9/20 14:08
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class RedisLists extends RedisUtils {
|
||||
|
||||
private RedisLists() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 list 区间
|
||||
*
|
||||
* @param key key
|
||||
* @return list
|
||||
*/
|
||||
public static List<String> range(String key) {
|
||||
// 查询列表
|
||||
List<String> elements = redisTemplate.opsForList().range(key, 0, -1);
|
||||
if (elements == null) {
|
||||
return Lists.newList();
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 list 区间
|
||||
*
|
||||
* @param key key
|
||||
* @param mapper mapper
|
||||
* @param <T> T
|
||||
* @return list
|
||||
*/
|
||||
public static <T> List<T> range(String key, Function<String, T> mapper) {
|
||||
// 查询列表
|
||||
List<String> elements = redisTemplate.opsForList().range(key, 0, -1);
|
||||
if (elements == null) {
|
||||
return Lists.newList();
|
||||
}
|
||||
return Lists.map(elements, mapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 list 区间
|
||||
*
|
||||
* @param define define
|
||||
* @return list
|
||||
*/
|
||||
public static <T> List<T> rangeJson(CacheKeyDefine define) {
|
||||
return rangeJson(define.getKey(), define);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 list 区间
|
||||
*
|
||||
* @param key key
|
||||
* @param define define
|
||||
* @return list
|
||||
*/
|
||||
public static <T> List<T> rangeJson(String key, CacheKeyDefine define) {
|
||||
// 查询列表
|
||||
List<String> elements = redisTemplate.opsForList().range(key, 0, -1);
|
||||
if (elements == null) {
|
||||
return Lists.newList();
|
||||
}
|
||||
return (List<T>) elements.stream()
|
||||
.map(s -> JSON.parseObject(s, define.getType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* list 添加元素
|
||||
*
|
||||
* @param key key
|
||||
* @param list list
|
||||
* @param mapper mapper
|
||||
* @param <T> T
|
||||
*/
|
||||
public static <T> void pushAll(String key, List<T> list, Function<T, String> mapper) {
|
||||
redisTemplate.opsForList().rightPushAll(key, Lists.map(list, mapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* list 添加元素
|
||||
*
|
||||
* @param key key
|
||||
* @param list list
|
||||
* @param <T> T
|
||||
*/
|
||||
public static <T> void pushAllJson(String key, List<T> list) {
|
||||
List<String> values = list.stream()
|
||||
.map(JSON::toJSONString)
|
||||
.collect(Collectors.toList());
|
||||
redisTemplate.opsForList().rightPushAll(key, values);
|
||||
}
|
||||
|
||||
/**
|
||||
* list 添加元素
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
* @param mapper mapper
|
||||
* @param <T> T
|
||||
*/
|
||||
public static <T> void push(String key, T value, Function<T, String> mapper) {
|
||||
redisTemplate.opsForList().rightPush(key, mapper.apply(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* list 添加元素
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
* @param <T> T
|
||||
*/
|
||||
public static <T> void pushJson(String key, T value) {
|
||||
redisTemplate.opsForList().rightPush(key, JSON.toJSONString(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* list 删除元素
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
* @param mapper mapper
|
||||
* @param <T> T
|
||||
*/
|
||||
public static <T> void remove(String key, T value, Function<T, String> mapper) {
|
||||
redisTemplate.opsForList().remove(key, 1, mapper.apply(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* list 删除元素
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
* @param <T> T
|
||||
*/
|
||||
public static <T> void removeJson(String key, T value) {
|
||||
redisTemplate.opsForList().remove(key, 1, JSON.toJSONString(value));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.orion.ops.framework.redis.core.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.orion.lang.define.cache.CacheKeyDefine;
|
||||
import com.orion.lang.utils.Strings;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* redis string 工具类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/9/20 14:05
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class RedisStrings extends RedisUtils {
|
||||
|
||||
private RedisStrings() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 json
|
||||
*
|
||||
* @param define define
|
||||
* @param <T> T
|
||||
* @return T
|
||||
*/
|
||||
public static <T> T getJson(CacheKeyDefine define) {
|
||||
return getJson(define.getKey(), define);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 json
|
||||
*
|
||||
* @param key key
|
||||
* @param define define
|
||||
* @param <T> T
|
||||
* @return T
|
||||
*/
|
||||
public static <T> T getJson(String key, CacheKeyDefine define) {
|
||||
String value = redisTemplate.opsForValue().get(key);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return (T) JSON.parseObject(value, define.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 json
|
||||
*
|
||||
* @param define define
|
||||
* @param <T> T
|
||||
* @return T
|
||||
*/
|
||||
public static <T> List<T> getJsonArray(CacheKeyDefine define) {
|
||||
return getJsonArray(define.getKey(), define);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 json
|
||||
*
|
||||
* @param key key
|
||||
* @param define define
|
||||
* @param <T> T
|
||||
* @return T
|
||||
*/
|
||||
public static <T> List<T> getJsonArray(String key, CacheKeyDefine define) {
|
||||
String value = redisTemplate.opsForValue().get(key);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return (List<T>) JSON.parseArray(value, define.getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 json
|
||||
*
|
||||
* @param key key
|
||||
* @param define define
|
||||
* @param value value
|
||||
*/
|
||||
public static void set(String key, CacheKeyDefine define, Object value) {
|
||||
if (value == null) {
|
||||
value = Strings.EMPTY;
|
||||
}
|
||||
if (define.getTimeout() == 0) {
|
||||
// 不过期
|
||||
redisTemplate.opsForValue().set(key, value.toString());
|
||||
} else {
|
||||
// 过期
|
||||
redisTemplate.opsForValue().set(key, value.toString(),
|
||||
define.getTimeout(),
|
||||
define.getUnit());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 json
|
||||
*
|
||||
* @param key key
|
||||
* @param define define
|
||||
* @param value value
|
||||
*/
|
||||
public static void setJson(String key, CacheKeyDefine define, Object value) {
|
||||
if (define.getTimeout() == 0) {
|
||||
// 不过期
|
||||
redisTemplate.opsForValue().set(key, JSON.toJSONString(value));
|
||||
} else {
|
||||
// 过期
|
||||
redisTemplate.opsForValue().set(key, JSON.toJSONString(value),
|
||||
define.getTimeout(),
|
||||
define.getUnit());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取并且设置 json
|
||||
*
|
||||
* @param define define
|
||||
* @param processor processor
|
||||
* @param params params
|
||||
* @param <T> type
|
||||
*/
|
||||
public static <T> void processSetJson(CacheKeyDefine define, Consumer<T> processor, Object... params) {
|
||||
processSetJson(define.format(params), define, processor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取并且设置 json
|
||||
*
|
||||
* @param key key
|
||||
* @param define define
|
||||
* @param processor processor
|
||||
* @param <T> type
|
||||
*/
|
||||
public static <T> void processSetJson(String key, CacheKeyDefine define, Consumer<T> processor) {
|
||||
String value = redisTemplate.opsForValue().get(key);
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
// 转换
|
||||
T cache = (T) JSON.parseObject(value, define.getType());
|
||||
// 执行处理逻辑
|
||||
processor.accept(cache);
|
||||
// 重新设置
|
||||
setJson(key, define, cache);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.orion.ops.framework.redis.core.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.orion.lang.define.cache.CacheKeyDefine;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.lang.utils.io.Streams;
|
||||
import org.springframework.data.redis.core.Cursor;
|
||||
import org.springframework.data.redis.core.RedisCallback;
|
||||
@@ -11,11 +8,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.ScanOptions;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* redis 工具类
|
||||
@@ -24,12 +17,11 @@ import java.util.stream.Collectors;
|
||||
* @version 1.0.0
|
||||
* @since 2021/11/6 11:09
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class RedisUtils {
|
||||
|
||||
private static RedisTemplate<String, String> redisTemplate;
|
||||
protected static RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
private RedisUtils() {
|
||||
protected RedisUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,199 +55,12 @@ public class RedisUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取并且设置 json
|
||||
* 设置过期时间
|
||||
*
|
||||
* @param define define
|
||||
* @param processor processor
|
||||
* @param params params
|
||||
* @param <T> type
|
||||
*/
|
||||
public static <T> void processSetJson(CacheKeyDefine define, Consumer<T> processor, Object... params) {
|
||||
processSetJson(define.format(params), define, processor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取并且设置 json
|
||||
*
|
||||
* @param key key
|
||||
* @param define define
|
||||
* @param processor processor
|
||||
* @param <T> type
|
||||
*/
|
||||
public static <T> void processSetJson(String key, CacheKeyDefine define, Consumer<T> processor) {
|
||||
String value = redisTemplate.opsForValue().get(key);
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
// 转换
|
||||
T cache = (T) JSON.parseObject(value, define.getType());
|
||||
// 执行处理逻辑
|
||||
processor.accept(cache);
|
||||
// 重新设置
|
||||
setJson(key, define, cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 json
|
||||
*
|
||||
* @param key key
|
||||
* @param define define
|
||||
* @param value value
|
||||
*/
|
||||
public static void set(String key, CacheKeyDefine define, Object value) {
|
||||
if (value == null) {
|
||||
value = Strings.EMPTY;
|
||||
}
|
||||
if (define.getTimeout() == 0) {
|
||||
// 不过期
|
||||
redisTemplate.opsForValue().set(key, value.toString());
|
||||
} else {
|
||||
// 过期
|
||||
redisTemplate.opsForValue().set(key, value.toString(),
|
||||
define.getTimeout(),
|
||||
define.getUnit());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置 json
|
||||
*
|
||||
* @param key key
|
||||
* @param define define
|
||||
* @param value value
|
||||
*/
|
||||
public static void setJson(String key, CacheKeyDefine define, Object value) {
|
||||
if (define.getTimeout() == 0) {
|
||||
// 不过期
|
||||
redisTemplate.opsForValue().set(key, JSON.toJSONString(value));
|
||||
} else {
|
||||
// 过期
|
||||
redisTemplate.opsForValue().set(key, JSON.toJSONString(value),
|
||||
define.getTimeout(),
|
||||
define.getUnit());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 list 区间
|
||||
*
|
||||
* @param key key
|
||||
* @return list
|
||||
*/
|
||||
public static List<String> listRange(String key) {
|
||||
// 查询列表
|
||||
List<String> elements = redisTemplate.opsForList().range(key, 0, -1);
|
||||
if (elements == null) {
|
||||
return Lists.newList();
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 list 区间
|
||||
*
|
||||
* @param key key
|
||||
* @param mapper mapper
|
||||
* @param <T> T
|
||||
* @return list
|
||||
*/
|
||||
public static <T> List<T> listRange(String key, Function<String, T> mapper) {
|
||||
// 查询列表
|
||||
List<String> elements = redisTemplate.opsForList().range(key, 0, -1);
|
||||
if (elements == null) {
|
||||
return Lists.newList();
|
||||
}
|
||||
return Lists.map(elements, mapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 list 区间
|
||||
*
|
||||
* @param key key
|
||||
* @param define define
|
||||
* @return list
|
||||
*/
|
||||
public static <T> List<T> listRangeJson(String key, CacheKeyDefine define) {
|
||||
// 查询列表
|
||||
List<String> elements = redisTemplate.opsForList().range(key, 0, -1);
|
||||
if (elements == null) {
|
||||
return Lists.newList();
|
||||
}
|
||||
return (List<T>) elements.stream()
|
||||
.map(s -> JSON.parseObject(s, define.getType()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* list 添加元素
|
||||
*
|
||||
* @param key key
|
||||
* @param list list
|
||||
* @param mapper mapper
|
||||
* @param <T> T
|
||||
*/
|
||||
public static <T> void listPushAll(String key, List<T> list, Function<T, String> mapper) {
|
||||
redisTemplate.opsForList().rightPushAll(key, Lists.map(list, mapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* list 添加元素
|
||||
*
|
||||
* @param key key
|
||||
* @param list list
|
||||
* @param <T> T
|
||||
*/
|
||||
public static <T> void listPushAllJson(String key, List<T> list) {
|
||||
List<String> values = list.stream()
|
||||
.map(JSON::toJSONString)
|
||||
.collect(Collectors.toList());
|
||||
redisTemplate.opsForList().rightPushAll(key, values);
|
||||
}
|
||||
|
||||
/**
|
||||
* list 添加元素
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
* @param mapper mapper
|
||||
* @param <T> T
|
||||
*/
|
||||
public static <T> void listPush(String key, T value, Function<T, String> mapper) {
|
||||
redisTemplate.opsForList().rightPush(key, mapper.apply(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* list 添加元素
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
* @param <T> T
|
||||
*/
|
||||
public static <T> void listPushJson(String key, T value) {
|
||||
redisTemplate.opsForList().rightPush(key, JSON.toJSONString(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* list 删除元素
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
* @param mapper mapper
|
||||
* @param <T> T
|
||||
*/
|
||||
public static <T> void listRemove(String key, T value, Function<T, String> mapper) {
|
||||
redisTemplate.opsForList().remove(key, 1, mapper.apply(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* list 删除元素
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
* @param <T> T
|
||||
*/
|
||||
public static <T> void listRemoveJson(String key, T value) {
|
||||
redisTemplate.opsForList().remove(key, 1, JSON.toJSONString(value));
|
||||
public static void setExpire(CacheKeyDefine define) {
|
||||
setExpire(define.getKey(), define);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,9 +48,11 @@ public class CodeGenerator {
|
||||
// .enums(UserStatusEnum.class),
|
||||
new GenTable("host_key", "主机秘钥", "host")
|
||||
.vue("asset", "host-key")
|
||||
.useDrawerForm()
|
||||
.ignoreTest(),
|
||||
new GenTable("host_identity", "主机身份", "host")
|
||||
.vue("asset", "host-identity")
|
||||
.useDrawerForm()
|
||||
.ignoreTest(),
|
||||
};
|
||||
// jdbc 配置 - 使用配置文件
|
||||
@@ -345,6 +347,8 @@ public class CodeGenerator {
|
||||
new String[]{"/templates/orion-vue-views-index.vue.vm", "index.vue", "vue/views/${module}/${feature}"},
|
||||
// form-modal.vue 文件
|
||||
new String[]{"/templates/orion-vue-views-components-form-modal.vue.vm", "${feature}-form-modal.vue", "vue/views/${module}/${feature}/components"},
|
||||
// form-drawer.vue 文件
|
||||
new String[]{"/templates/orion-vue-views-components-form-drawer.vue.vm", "${feature}-form-drawer.vue", "vue/views/${module}/${feature}/components"},
|
||||
// table.vue 文件
|
||||
new String[]{"/templates/orion-vue-views-components-table.vue.vm", "${feature}-table.vue", "vue/views/${module}/${feature}/components"},
|
||||
// enum.types.ts 文件
|
||||
|
||||
@@ -60,6 +60,11 @@ public class GenTable {
|
||||
*/
|
||||
private String feature;
|
||||
|
||||
/**
|
||||
* 使用抽屉表单
|
||||
*/
|
||||
private boolean drawerForm;
|
||||
|
||||
/**
|
||||
* 生成的枚举文件
|
||||
*/
|
||||
@@ -108,6 +113,16 @@ public class GenTable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用抽屉表单
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public GenTable useDrawerForm() {
|
||||
this.drawerForm = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 vue 枚举对象
|
||||
*
|
||||
|
||||
@@ -1,49 +1,44 @@
|
||||
<template>
|
||||
<a-modal v-model:visible="visible"
|
||||
body-class="modal-form"
|
||||
title-align="start"
|
||||
:title="title"
|
||||
:top="80"
|
||||
:align-center="false"
|
||||
:draggable="true"
|
||||
:mask-closable="false"
|
||||
:unmount-on-close="true"
|
||||
:ok-button-props="{ disabled: loading }"
|
||||
:cancel-button-props="{ disabled: loading }"
|
||||
:on-before-ok="handlerOk"
|
||||
@close="handleClose">
|
||||
<a-drawer :visible="visible"
|
||||
:title="title"
|
||||
:width="430"
|
||||
:mask-closable="false"
|
||||
:unmount-on-close="true"
|
||||
:on-before-ok="handlerOk"
|
||||
@cancel="handleClose">
|
||||
<a-spin :loading="loading">
|
||||
<a-form :model="formModel"
|
||||
ref="formRef"
|
||||
label-align="right"
|
||||
:style="{ width: '460px' }"
|
||||
:style="{ width: '380px' }"
|
||||
:label-col-props="{ span: 6 }"
|
||||
:wrapper-col-props="{ span: 18 }"
|
||||
:rules="formRules">
|
||||
<!-- 名称 -->
|
||||
<a-form-item field="name" label="名称">
|
||||
<a-input v-model="formModel.name" placeholder="请输入名称" />
|
||||
</a-form-item>
|
||||
<!-- 公钥文本 -->
|
||||
<a-form-item field="publicKey" label="公钥文本">
|
||||
<a-input v-model="formModel.publicKey" placeholder="请输入公钥文本" />
|
||||
</a-form-item>
|
||||
<!-- 私钥文本 -->
|
||||
<a-form-item field="privateKey" label="私钥文本">
|
||||
<a-input v-model="formModel.privateKey" placeholder="请输入私钥文本" />
|
||||
</a-form-item>
|
||||
<!-- 密码 -->
|
||||
<a-form-item field="password" label="密码">
|
||||
<a-input v-model="formModel.password" placeholder="请输入密码" />
|
||||
#foreach($field in ${table.fields})
|
||||
#if("$field.propertyName" != "id")
|
||||
<!-- $field.comment -->
|
||||
<a-form-item field="${field.propertyName}" label="${field.comment}">
|
||||
#if("$field.propertyType" == "Integer" || "$field.propertyType" == "Long")
|
||||
<a-input-number v-model="formModel.${field.propertyName}" placeholder="请输入${field.comment}" />
|
||||
#elseif("$field.propertyType" == "Date")
|
||||
<a-date-picker v-model="formModel.${field.propertyName}"
|
||||
style="width: 100%"
|
||||
placeholder="请选择${field.comment}"
|
||||
show-time />
|
||||
#else
|
||||
<a-input v-model="formModel.${field.propertyName}" placeholder="请输入${field.comment}" />
|
||||
#end
|
||||
</a-form-item>
|
||||
#end
|
||||
#end
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</a-modal>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'asset-host-key-form-modal'
|
||||
name: '${vue.module}-${vue.feature}-form-drawer'
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -52,10 +47,10 @@
|
||||
import useLoading from '@/hooks/loading';
|
||||
import useVisible from '@/hooks/visible';
|
||||
import formRules from '../types/form.rules';
|
||||
import { createHostKey, updateHostKey } from '@/api/asset/host-key';
|
||||
import { create${vue.featureEntity}, update${vue.featureEntity} } from '@/api/${vue.module}/${vue.feature}';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { } from '../types/enum.types';
|
||||
import { } from '../types/const';
|
||||
import {} from '../types/enum.types';
|
||||
import {} from '../types/const';
|
||||
import { toOptions } from '@/utils/enum';
|
||||
|
||||
const { visible, setVisible } = useVisible();
|
||||
@@ -66,11 +61,9 @@
|
||||
|
||||
const defaultForm = () => {
|
||||
return {
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
publicKey: undefined,
|
||||
privateKey: undefined,
|
||||
password: undefined,
|
||||
#foreach($field in ${table.fields})
|
||||
${field.propertyName}: undefined,
|
||||
#end
|
||||
};
|
||||
};
|
||||
|
||||
@@ -81,7 +74,7 @@
|
||||
|
||||
// 打开新增
|
||||
const openAdd = () => {
|
||||
title.value = '添加主机秘钥';
|
||||
title.value = '添加${table.comment}';
|
||||
isAddHandle.value = true;
|
||||
renderForm({ ...defaultForm() });
|
||||
setVisible(true);
|
||||
@@ -89,7 +82,7 @@
|
||||
|
||||
// 打开修改
|
||||
const openUpdate = (record: any) => {
|
||||
title.value = '修改主机秘钥';
|
||||
title.value = '修改${table.comment}';
|
||||
isAddHandle.value = false;
|
||||
renderForm({ ...defaultForm(), ...record });
|
||||
setVisible(true);
|
||||
@@ -115,12 +108,12 @@
|
||||
}
|
||||
if (isAddHandle.value) {
|
||||
// 新增
|
||||
await createHostKey(formModel as any);
|
||||
await create${vue.featureEntity}(formModel as any);
|
||||
Message.success('创建成功');
|
||||
emits('added');
|
||||
} else {
|
||||
// 修改
|
||||
await updateHostKey(formModel as any);
|
||||
await update${vue.featureEntity}(formModel as any);
|
||||
Message.success('修改成功');
|
||||
emits('updated');
|
||||
}
|
||||
@@ -55,8 +55,8 @@
|
||||
import formRules from '../types/form.rules';
|
||||
import { create${vue.featureEntity}, update${vue.featureEntity} } from '@/api/${vue.module}/${vue.feature}';
|
||||
import { Message } from '@arco-design/web-vue';
|
||||
import { } from '../types/enum.types';
|
||||
import { } from '../types/const';
|
||||
import {} from '../types/enum.types';
|
||||
import {} from '../types/const';
|
||||
import { toOptions } from '@/utils/enum';
|
||||
|
||||
const { visible, setVisible } = useVisible();
|
||||
|
||||
@@ -115,8 +115,8 @@
|
||||
import useLoading from '@/hooks/loading';
|
||||
import columns from '../types/table.columns';
|
||||
import { defaultPagination, defaultRowSelection } from '@/types/table';
|
||||
import { } from '../types/enum.types';
|
||||
import { } from '../types/const';
|
||||
import {} from '../types/enum.types';
|
||||
import {} from '../types/const';
|
||||
import { toOptions } from '@/utils/enum';
|
||||
|
||||
const tableRenderData = ref<${vue.featureEntity}QueryResponse[]>();
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
<template>
|
||||
<div class="layout-container">
|
||||
#if($vue.drawerForm)
|
||||
<!-- 表格 -->
|
||||
<${vue.feature}-table ref="table"
|
||||
@openAdd="() => drawer.openAdd()"
|
||||
@openUpdate="(e) => drawer.openUpdate(e)" />
|
||||
<!-- 添加修改模态框 -->
|
||||
<${vue.feature}-form-drawer ref="drawer"
|
||||
@added="() => table.addedCallback()"
|
||||
@updated="() => table.updatedCallback()" />
|
||||
#else
|
||||
<!-- 表格 -->
|
||||
<${vue.feature}-table ref="table"
|
||||
@openAdd="() => modal.openAdd()"
|
||||
@openUpdate="(e) => modal.openUpdate(e)" />
|
||||
<!-- 添加修改模态框 -->
|
||||
<${vue.feature}-form-modal ref="modal"
|
||||
@added="() => table.addedCallback()"
|
||||
@updated="() => table.updatedCallback()" />
|
||||
@added="() => table.addedCallback()"
|
||||
@updated="() => table.updatedCallback()" />
|
||||
#end
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -19,11 +31,20 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import ${vue.featureEntity}Table from './components/${vue.feature}-table.vue';
|
||||
#if($vue.drawerForm)
|
||||
import ${vue.featureEntity}FormDrawer from './components/${vue.feature}-form-drawer.vue';
|
||||
#else
|
||||
import ${vue.featureEntity}FormModal from './components/${vue.feature}-form-modal.vue';
|
||||
#end
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
const table = ref();
|
||||
#if($vue.drawerForm)
|
||||
const drawer = ref();
|
||||
#else
|
||||
const modal = ref();
|
||||
#end
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.orion.ops.framework.common.utils.CryptoUtils;
|
||||
import com.orion.ops.framework.common.utils.IpUtils;
|
||||
import com.orion.ops.framework.common.utils.Kits;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisStrings;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisUtils;
|
||||
import com.orion.ops.module.infra.convert.SystemUserConvert;
|
||||
import com.orion.ops.module.infra.dao.SystemUserDAO;
|
||||
@@ -153,10 +154,10 @@ public class AuthenticationServiceImpl implements AuthenticationService {
|
||||
int refreshCount = refresh.getRefreshCount() + 1;
|
||||
refresh.setRefreshCount(refreshCount);
|
||||
// 设置登陆缓存
|
||||
RedisUtils.setJson(loginKey, UserCacheKeyDefine.LOGIN_TOKEN, refresh);
|
||||
RedisStrings.setJson(loginKey, UserCacheKeyDefine.LOGIN_TOKEN, refresh);
|
||||
if (refreshCount < maxRefreshCount) {
|
||||
// 小于续签最大次数 则再次设置 refreshToken
|
||||
RedisUtils.setJson(refreshKey, UserCacheKeyDefine.LOGIN_REFRESH, refresh);
|
||||
RedisStrings.setJson(refreshKey, UserCacheKeyDefine.LOGIN_REFRESH, refresh);
|
||||
} else {
|
||||
// 大于等于续签最大次数 则删除
|
||||
redisTemplate.delete(refreshKey);
|
||||
@@ -239,7 +240,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
|
||||
// 修改缓存状态
|
||||
LoginUser loginUser = JSON.parseObject(userInfoCache, LoginUser.class);
|
||||
loginUser.setStatus(UserStatusEnum.LOCKED.getStatus());
|
||||
RedisUtils.setJson(userInfoKey, UserCacheKeyDefine.USER_INFO, loginUser);
|
||||
RedisStrings.setJson(userInfoKey, UserCacheKeyDefine.USER_INFO, loginUser);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -290,7 +291,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
|
||||
String userInfoKey = UserCacheKeyDefine.USER_INFO.format(id);
|
||||
LoginUser loginUser = SystemUserConvert.MAPPER.toLoginUser(user);
|
||||
loginUser.setRoles(roleCodeList);
|
||||
RedisUtils.setJson(userInfoKey, UserCacheKeyDefine.USER_INFO, loginUser);
|
||||
RedisStrings.setJson(userInfoKey, UserCacheKeyDefine.USER_INFO, loginUser);
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
@@ -323,7 +324,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
|
||||
loginTokenInfo.setLoginTime(loginTime);
|
||||
loginTokenInfo.setIp(remoteAddr);
|
||||
loginTokenInfo.setLocation(location);
|
||||
RedisUtils.setJson(deviceLoginKey, UserCacheKeyDefine.LOGIN_TOKEN, loginTokenInfo);
|
||||
RedisStrings.setJson(deviceLoginKey, UserCacheKeyDefine.LOGIN_TOKEN, loginTokenInfo);
|
||||
}
|
||||
}
|
||||
// 删除续签信息
|
||||
@@ -358,11 +359,11 @@ public class AuthenticationServiceImpl implements AuthenticationService {
|
||||
.loginTime(loginTime)
|
||||
.location(location)
|
||||
.build();
|
||||
RedisUtils.setJson(loginKey, UserCacheKeyDefine.LOGIN_TOKEN, loginValue);
|
||||
RedisStrings.setJson(loginKey, UserCacheKeyDefine.LOGIN_TOKEN, loginValue);
|
||||
// 生成 refreshToken
|
||||
if (allowRefresh) {
|
||||
String refreshKey = UserCacheKeyDefine.LOGIN_REFRESH.format(id, loginTime);
|
||||
RedisUtils.setJson(refreshKey, UserCacheKeyDefine.LOGIN_REFRESH, loginValue);
|
||||
RedisStrings.setJson(refreshKey, UserCacheKeyDefine.LOGIN_REFRESH, loginValue);
|
||||
}
|
||||
// 返回token
|
||||
return CryptoUtils.encryptBase62(id + ":" + loginTime);
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisUtils;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisLists;
|
||||
import com.orion.ops.framework.security.core.utils.SecurityUtils;
|
||||
import com.orion.ops.module.infra.convert.FavoriteConvert;
|
||||
import com.orion.ops.module.infra.dao.FavoriteDAO;
|
||||
@@ -53,9 +53,9 @@ public class FavoriteServiceImpl implements FavoriteService {
|
||||
int effect = favoriteDAO.insert(record);
|
||||
// 设置缓存
|
||||
String key = FavoriteCacheKeyDefine.FAVORITE.format(type, userId);
|
||||
RedisUtils.listPush(key, request.getRelId(), String::valueOf);
|
||||
RedisLists.push(key, request.getRelId(), String::valueOf);
|
||||
// 设置过期时间
|
||||
RedisUtils.setExpire(key, FavoriteCacheKeyDefine.FAVORITE);
|
||||
RedisLists.setExpire(key, FavoriteCacheKeyDefine.FAVORITE);
|
||||
return record.getId();
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class FavoriteServiceImpl implements FavoriteService {
|
||||
Long userId = request.getUserId();
|
||||
String cacheKey = FavoriteCacheKeyDefine.FAVORITE.format(type, userId);
|
||||
// 获取缓存
|
||||
List<Long> cacheRelIdList = RedisUtils.listRange(cacheKey, Long::valueOf);
|
||||
List<Long> cacheRelIdList = RedisLists.range(cacheKey, Long::valueOf);
|
||||
if (cacheRelIdList.isEmpty()) {
|
||||
// 条件
|
||||
LambdaQueryWrapper<FavoriteDO> wrapper = this.buildQueryWrapper(request);
|
||||
@@ -101,9 +101,9 @@ public class FavoriteServiceImpl implements FavoriteService {
|
||||
cacheRelIdList.add(Const.NONE_ID);
|
||||
}
|
||||
// 设置缓存
|
||||
RedisUtils.listPushAll(cacheKey, cacheRelIdList, String::valueOf);
|
||||
RedisLists.pushAll(cacheKey, cacheRelIdList, String::valueOf);
|
||||
// 设置过期时间
|
||||
RedisUtils.setExpire(cacheKey, FavoriteCacheKeyDefine.FAVORITE);
|
||||
RedisLists.setExpire(cacheKey, FavoriteCacheKeyDefine.FAVORITE);
|
||||
}
|
||||
// 删除防止穿透的 key
|
||||
cacheRelIdList.remove(Const.NONE_ID);
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.security.LoginUser;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisUtils;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisStrings;
|
||||
import com.orion.ops.module.infra.dao.SystemRoleDAO;
|
||||
import com.orion.ops.module.infra.dao.SystemUserDAO;
|
||||
import com.orion.ops.module.infra.dao.SystemUserRoleDAO;
|
||||
@@ -54,7 +54,7 @@ public class SystemUserRoleServiceImpl implements SystemUserRoleService {
|
||||
// 删除用户关联
|
||||
int effect = systemUserRoleDAO.deleteByUserId(userId);
|
||||
// 更新缓存中的角色
|
||||
RedisUtils.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
RedisStrings.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
s.setRoles(Lists.empty());
|
||||
}, userId);
|
||||
return effect;
|
||||
@@ -92,7 +92,7 @@ public class SystemUserRoleServiceImpl implements SystemUserRoleService {
|
||||
systemUserRoleDAO.insertBatch(addUserRoles);
|
||||
effect += addUserRoles.size();
|
||||
// 更新缓存中的角色
|
||||
RedisUtils.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
RedisStrings.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
List<String> roleCodeList = userRoles.stream()
|
||||
.map(SystemRoleDO::getCode)
|
||||
.collect(Collectors.toList());
|
||||
@@ -105,7 +105,7 @@ public class SystemUserRoleServiceImpl implements SystemUserRoleService {
|
||||
@Async("asyncExecutor")
|
||||
public void asyncDeleteUserCacheRole(String roleCode, List<Long> userIdList) {
|
||||
for (Long userId : userIdList) {
|
||||
RedisUtils.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
RedisStrings.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
List<String> roles = s.getRoles();
|
||||
if (Lists.isEmpty(roles)) {
|
||||
return;
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.orion.ops.framework.common.constant.ErrorCode;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.security.LoginUser;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisStrings;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisUtils;
|
||||
import com.orion.ops.framework.security.core.utils.SecurityUtils;
|
||||
import com.orion.ops.module.infra.convert.SystemUserConvert;
|
||||
@@ -82,7 +83,7 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
int effect = systemUserDAO.updateById(updateRecord);
|
||||
log.info("SystemUserService-updateSystemUserById effect: {}, updateRecord: {}", effect, JSON.toJSONString(updateRecord));
|
||||
// 更新缓存中的花名
|
||||
RedisUtils.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
RedisStrings.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
s.setNickname(request.getNickname());
|
||||
}, id);
|
||||
return effect;
|
||||
@@ -112,7 +113,7 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
redisTemplate.delete(UserCacheKeyDefine.LOGIN_FAILED_COUNT.format(record.getUsername()));
|
||||
}
|
||||
// 更新缓存中的status
|
||||
RedisUtils.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
RedisStrings.<LoginUser>processSetJson(UserCacheKeyDefine.USER_INFO, s -> {
|
||||
s.setStatus(request.getStatus());
|
||||
}, id);
|
||||
return effect;
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.lang.utils.collect.Maps;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisUtils;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisStrings;
|
||||
import com.orion.ops.module.infra.convert.TagRelConvert;
|
||||
import com.orion.ops.module.infra.dao.TagDAO;
|
||||
import com.orion.ops.module.infra.dao.TagRelDAO;
|
||||
@@ -63,7 +63,7 @@ public class TagRelServiceImpl implements TagRelService {
|
||||
tagRelDAO.insertBatch(tagRelList);
|
||||
// 设置缓存
|
||||
String cacheKey = TagCacheKeyDefine.TAG_REL.format(type, relId);
|
||||
RedisUtils.setJson(cacheKey, TagCacheKeyDefine.TAG_REL, TagRelConvert.MAPPER.toCacheList(tagRelList));
|
||||
RedisStrings.setJson(cacheKey, TagCacheKeyDefine.TAG_REL, TagRelConvert.MAPPER.toCacheList(tagRelList));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -90,7 +90,7 @@ public class TagRelServiceImpl implements TagRelService {
|
||||
List<TagRelDO> relList = tagRelDAO.selectList(wrapper);
|
||||
// 设置缓存
|
||||
List<TagCacheDTO> relCacheList = TagRelConvert.MAPPER.toCacheList(relList);
|
||||
RedisUtils.setJson(cacheKey, TagCacheKeyDefine.TAG_REL, relCacheList);
|
||||
RedisStrings.setJson(cacheKey, TagCacheKeyDefine.TAG_REL, relCacheList);
|
||||
return relCacheList;
|
||||
} else {
|
||||
// 返回缓存数据
|
||||
@@ -135,7 +135,7 @@ public class TagRelServiceImpl implements TagRelService {
|
||||
if (cacheValue == null) {
|
||||
cacheValue = Lists.empty();
|
||||
}
|
||||
RedisUtils.setJson(cacheKey, TagCacheKeyDefine.TAG_REL, cacheValue);
|
||||
RedisStrings.setJson(cacheKey, TagCacheKeyDefine.TAG_REL, cacheValue);
|
||||
emptyCacheMap.put(relId, cacheValue);
|
||||
});
|
||||
// 设置返回
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
import com.orion.ops.framework.mybatis.core.query.Conditions;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisUtils;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisLists;
|
||||
import com.orion.ops.module.infra.convert.TagConvert;
|
||||
import com.orion.ops.module.infra.dao.TagDAO;
|
||||
import com.orion.ops.module.infra.define.TagCacheKeyDefine;
|
||||
@@ -52,8 +52,8 @@ public class TagServiceImpl implements TagService {
|
||||
// 设置缓存
|
||||
String cacheKey = TagCacheKeyDefine.TAG_NAME.format(type);
|
||||
TagCacheDTO cache = TagConvert.MAPPER.toCache(record);
|
||||
RedisUtils.listPushJson(cacheKey, cache);
|
||||
RedisUtils.setExpire(cacheKey, TagCacheKeyDefine.TAG_NAME);
|
||||
RedisLists.pushJson(cacheKey, cache);
|
||||
RedisLists.setExpire(cacheKey, TagCacheKeyDefine.TAG_NAME);
|
||||
return record.getId();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public class TagServiceImpl implements TagService {
|
||||
public List<TagVO> getTagList(String type) {
|
||||
// 查询缓存
|
||||
String cacheKey = TagCacheKeyDefine.TAG_NAME.format(type);
|
||||
List<TagCacheDTO> cacheValues = RedisUtils.listRangeJson(cacheKey, TagCacheKeyDefine.TAG_NAME);
|
||||
List<TagCacheDTO> cacheValues = RedisLists.rangeJson(cacheKey, TagCacheKeyDefine.TAG_NAME);
|
||||
if (cacheValues.isEmpty()) {
|
||||
// 为空则需要查询缓存
|
||||
LambdaQueryWrapper<TagDO> wrapper = Conditions.eq(TagDO::getType, type);
|
||||
@@ -71,8 +71,8 @@ public class TagServiceImpl implements TagService {
|
||||
cacheValues.add(TagCacheDTO.builder().id(Const.NONE_ID).build());
|
||||
}
|
||||
// 设置到缓存
|
||||
RedisUtils.listPushAllJson(cacheKey, cacheValues);
|
||||
RedisUtils.setExpire(cacheKey, TagCacheKeyDefine.TAG_NAME);
|
||||
RedisLists.pushAllJson(cacheKey, cacheValues);
|
||||
RedisLists.setExpire(cacheKey, TagCacheKeyDefine.TAG_NAME);
|
||||
}
|
||||
// 删除防止穿透的 key
|
||||
cacheValues.removeIf(s -> Const.NONE_ID.equals(s.getId()));
|
||||
@@ -91,7 +91,7 @@ public class TagServiceImpl implements TagService {
|
||||
log.info("TagService-deleteTagById id: {}, effect: {}", id, effect);
|
||||
// 删除缓存
|
||||
String cacheKey = TagCacheKeyDefine.TAG_NAME.format(tag.getType());
|
||||
RedisUtils.listRemoveJson(cacheKey, TagConvert.MAPPER.toCache(tag));
|
||||
RedisLists.removeJson(cacheKey, TagConvert.MAPPER.toCache(tag));
|
||||
return effect;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class TagServiceImpl implements TagService {
|
||||
// 删除缓存
|
||||
for (TagDO tag : tagList) {
|
||||
String cacheKey = TagCacheKeyDefine.TAG_NAME.format(tag.getType());
|
||||
RedisUtils.listRemoveJson(cacheKey, TagConvert.MAPPER.toCache(tag));
|
||||
RedisLists.removeJson(cacheKey, TagConvert.MAPPER.toCache(tag));
|
||||
}
|
||||
return effect;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user