From c76df15a7f72ed46a446e04f4b2c6793afcfde5b Mon Sep 17 00:00:00 2001 From: xiongxiaoyang <1179705413@qq.com> Date: Fri, 14 Apr 2023 16:32:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=90=8E=E5=8F=B0=E5=8F=8B=E6=83=85?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/sql/20230413.sql | 28 + doc/sql/novel_plus.sql | 31 +- .../com/java2nb/common/config/CacheKey.java | 73 +++ .../java2nb/common/config/RedisConfig.java | 82 --- .../com/java2nb/common/utils/RedisUtil.java | 601 ------------------ .../controller/FriendLinkController.java | 135 ++++ .../com/java2nb/novel/dao/FriendLinkDao.java | 32 + .../java2nb/novel/domain/FriendLinkDO.java | 163 +++++ .../novel/service/FriendLinkService.java | 30 + .../service/impl/FriendLinkServiceImpl.java | 55 ++ .../system/controller/SysUserController.java | 396 ++++++------ .../mybatis/novel/FriendLinkMapper.xml | 131 ++++ .../static/js/appjs/novel/friendLink/add.js | 107 ++++ .../static/js/appjs/novel/friendLink/edit.js | 103 +++ .../js/appjs/novel/friendLink/friendLink.js | 205 ++++++ .../static/sql/novel/friendLink/menu.js | 18 + .../templates/novel/friendLink/add.html | 67 ++ .../templates/novel/friendLink/detail.html | 100 +++ .../templates/novel/friendLink/edit.html | 69 ++ .../novel/friendLink/friendLink.html | 59 ++ 20 files changed, 1605 insertions(+), 880 deletions(-) create mode 100644 novel-admin/src/main/java/com/java2nb/common/config/CacheKey.java delete mode 100644 novel-admin/src/main/java/com/java2nb/common/config/RedisConfig.java delete mode 100644 novel-admin/src/main/java/com/java2nb/common/utils/RedisUtil.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/controller/FriendLinkController.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/dao/FriendLinkDao.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/domain/FriendLinkDO.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/service/FriendLinkService.java create mode 100644 novel-admin/src/main/java/com/java2nb/novel/service/impl/FriendLinkServiceImpl.java create mode 100644 novel-admin/src/main/resources/mybatis/novel/FriendLinkMapper.xml create mode 100644 novel-admin/src/main/resources/static/js/appjs/novel/friendLink/add.js create mode 100644 novel-admin/src/main/resources/static/js/appjs/novel/friendLink/edit.js create mode 100644 novel-admin/src/main/resources/static/js/appjs/novel/friendLink/friendLink.js create mode 100644 novel-admin/src/main/resources/static/sql/novel/friendLink/menu.js create mode 100644 novel-admin/src/main/resources/templates/novel/friendLink/add.html create mode 100644 novel-admin/src/main/resources/templates/novel/friendLink/detail.html create mode 100644 novel-admin/src/main/resources/templates/novel/friendLink/edit.html create mode 100644 novel-admin/src/main/resources/templates/novel/friendLink/friendLink.html diff --git a/doc/sql/20230413.sql b/doc/sql/20230413.sql index 4cc3100..f47d750 100644 --- a/doc/sql/20230413.sql +++ b/doc/sql/20230413.sql @@ -36,3 +36,31 @@ VALUES (1, 300); INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 301); + +INSERT INTO `sys_menu` (menu_id, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (310, 300, '友情链接', 'novel/friendLink', 'novel:friendLink:friendLink', '1', 'fa', '16'); + +INSERT INTO `sys_menu` (menu_id, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (311, 310, '查看', null, 'novel:friendLink:detail', '2', null, '6'); +INSERT INTO `sys_menu` (menu_id, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (312, 310, '新增', null, 'novel:friendLink:add', '2', null, '6'); +INSERT INTO `sys_menu` (menu_id, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (313, 310, '修改', null, 'novel:friendLink:edit', '2', null, '6'); +INSERT INTO `sys_menu` (menu_id, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (314, 310, '删除', null, 'novel:friendLink:remove', '2', null, '6'); +INSERT INTO `sys_menu` (menu_id, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (315, 310, '批量删除', null, 'novel:friendLink:batchRemove', '2', null, '6'); + + +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 310); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 311); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 312); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 313); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 314); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 315); diff --git a/doc/sql/novel_plus.sql b/doc/sql/novel_plus.sql index 2893f65..28269fe 100644 --- a/doc/sql/novel_plus.sql +++ b/doc/sql/novel_plus.sql @@ -2866,4 +2866,33 @@ VALUES (301, 300, '网站信息', 'novel/websiteInfo', 'novel:websiteInfo:websit INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 300); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (1, 301); \ No newline at end of file +VALUES (1, 301); + + +INSERT INTO `sys_menu` (menu_id, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (310, 300, '友情链接', 'novel/friendLink', 'novel:friendLink:friendLink', '1', 'fa', '16'); + +INSERT INTO `sys_menu` (menu_id, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (311, 310, '查看', null, 'novel:friendLink:detail', '2', null, '6'); +INSERT INTO `sys_menu` (menu_id, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (312, 310, '新增', null, 'novel:friendLink:add', '2', null, '6'); +INSERT INTO `sys_menu` (menu_id, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (313, 310, '修改', null, 'novel:friendLink:edit', '2', null, '6'); +INSERT INTO `sys_menu` (menu_id, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (314, 310, '删除', null, 'novel:friendLink:remove', '2', null, '6'); +INSERT INTO `sys_menu` (menu_id, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) +VALUES (315, 310, '批量删除', null, 'novel:friendLink:batchRemove', '2', null, '6'); + + +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 310); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 311); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 312); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 313); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 314); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 315); diff --git a/novel-admin/src/main/java/com/java2nb/common/config/CacheKey.java b/novel-admin/src/main/java/com/java2nb/common/config/CacheKey.java new file mode 100644 index 0000000..af20c35 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/common/config/CacheKey.java @@ -0,0 +1,73 @@ +package com.java2nb.common.config; + +/** + * @author 11797 + */ +public interface CacheKey { + + /** + * 首页小说设置 + */ + String INDEX_BOOK_SETTINGS_KEY = "indexBookSettingsKey"; + + /** + * 首页新闻 + */ + String INDEX_NEWS_KEY = "indexNewsKey"; + + /** + * 首页点击榜单 + */ + String INDEX_CLICK_BANK_BOOK_KEY = "indexClickBankBookKey"; + + /** + * 首页友情链接 + */ + String INDEX_LINK_KEY = "indexLinkKey"; + + /** + * 首页新书榜单 + */ + String INDEX_NEW_BOOK_KEY = "indexNewBookKey"; + + + /** + * 首页更新榜单 + */ + String INDEX_UPDATE_BOOK_KEY = "indexUpdateBookKey"; + + /** + * 模板目录保存key + */ + String TEMPLATE_DIR_KEY = "templateDirKey"; + ; + + /** + * 正在运行的爬虫线程存储KEY前缀 + */ + String RUNNING_CRAWL_THREAD_KEY_PREFIX = "runningCrawlTreadDataKeyPrefix"; + + /** + * 上一次搜索引擎更新的时间 + */ + String ES_LAST_UPDATE_TIME = "esLastUpdateTime"; + + /** + * 搜索引擎转换锁 + */ + String ES_TRANS_LOCK = "esTransLock"; + + /** + * 上一次搜索引擎是否更新过小说点击量 + */ + String ES_IS_UPDATE_VISIT = "esIsUpdateVisit"; + + /** + * 累积的小说点击量 + */ + String BOOK_ADD_VISIT_COUNT = "bookAddVisitCount"; + /** + * 测试爬虫规则缓存 + */ + String BOOK_TEST_PARSE = "testParse"; +} diff --git a/novel-admin/src/main/java/com/java2nb/common/config/RedisConfig.java b/novel-admin/src/main/java/com/java2nb/common/config/RedisConfig.java deleted file mode 100644 index c5a0c10..0000000 --- a/novel-admin/src/main/java/com/java2nb/common/config/RedisConfig.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.java2nb.common.config; - - -import com.fasterxml.jackson.annotation.JsonAutoDetect; -import com.fasterxml.jackson.annotation.PropertyAccessor; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; -import org.springframework.data.redis.serializer.StringRedisSerializer; - -@Configuration -public class RedisConfig { - - - @Bean - @SuppressWarnings("all") - public RedisTemplate redisTemplate(RedisConnectionFactory factory) { - - - RedisTemplate template = new RedisTemplate(); - - - template.setConnectionFactory(factory); - - - Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); - - - ObjectMapper om = new ObjectMapper(); - - - om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); - - - om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); - - - jackson2JsonRedisSerializer.setObjectMapper(om); - - - StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); - - - // key采用String的序列化方式 - - - template.setKeySerializer(stringRedisSerializer); - - - // hash的key也采用String的序列化方式 - - - template.setHashKeySerializer(stringRedisSerializer); - - - // value序列化方式采用jackson - - - template.setValueSerializer(jackson2JsonRedisSerializer); - - - // hash的value序列化方式采用jackson - - - template.setHashValueSerializer(jackson2JsonRedisSerializer); - - - template.afterPropertiesSet(); - - - return template; - - - } - - -} - - diff --git a/novel-admin/src/main/java/com/java2nb/common/utils/RedisUtil.java b/novel-admin/src/main/java/com/java2nb/common/utils/RedisUtil.java deleted file mode 100644 index 071b17d..0000000 --- a/novel-admin/src/main/java/com/java2nb/common/utils/RedisUtil.java +++ /dev/null @@ -1,601 +0,0 @@ -package com.java2nb.common.utils; - -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeUnit; - -@Component -@Slf4j -public final class RedisUtil { - - - @Autowired - private RedisTemplate redisTemplate; - - /** - * 指定缓存失效时间 - * - * @param key 键 - * @param time 时间(秒) - * @return - */ - - - public boolean expire(String key, long time) { - try { - if (time > 0) { - redisTemplate.expire(key, time, TimeUnit.SECONDS); - } - return true; - } catch (Exception e) { - log.error(e.getMessage(),e); - return false; - } - } - - - /** - * 根据key 获取过期时间 - * - * @param key 键 不能为null - * @return 时间(秒) 返回0代表为永久有效 - */ - - - public long getExpire(String key) { - return redisTemplate.getExpire(key, TimeUnit.SECONDS); - } - - - /** - * 判断key是否存在 - * - * @param key 键 - * @return true 存在 false不存在 - */ - - - public boolean hasKey(String key) { - try { - return redisTemplate.hasKey(key); - } catch (Exception e) { - log.error(e.getMessage(),e); - return false; - } - } - - - /** - * 删除缓存 - * - * @param key 可以传一个值 或多个 - */ - public void del(String... key) { - if (key != null && key.length > 0) { - if (key.length == 1) { - redisTemplate.delete(key[0]); - } else { - redisTemplate.delete(CollectionUtils.arrayToList(key)); - } - } - } - - /** - * 普通缓存获取 - * - * @param key 键 - * @return 值 - */ - public Object get(String key) { - return key == null ? null : redisTemplate.opsForValue().get(key); - } - - - /** - * 普通缓存放入 - * - * @param key 键 - * @param value 值 - * @return true成功 false失败 - */ - public boolean set(String key, Object value) { - try { - redisTemplate.opsForValue().set(key, value); - return true; - } catch (Exception e) { - log.error(e.getMessage(),e); - return false; - } - } - - - /** - * 普通缓存放入并设置时间 - * - * @param key 键 - * @param value 值 - * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 - * @return true成功 false 失败 - */ - public boolean set(String key, Object value, long time) { - try { - if (time > 0) { - redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); - } else { - set(key, value); - } - return true; - } catch (Exception e) { - log.error(e.getMessage(),e); - return false; - } - } - - - /** - * 递增 - * - * @param key 键 - * @param delta 要增加几(大于0) - * @return - */ - public long incr(String key, long delta) { - if (delta < 0) { - throw new RuntimeException("递增因子必须大于0"); - } - return redisTemplate.opsForValue().increment(key, delta); - } - - - /** - * 递减 - * - * @param key 键 - * @param delta 要减少几(小于0) - * @return - */ - public long decr(String key, long delta) { - if (delta < 0) { - throw new RuntimeException("递减因子必须大于0"); - } - return redisTemplate.opsForValue().increment(key, -delta); - } - - - // ================================Map================================= - - - /** - * HashGet - * - * @param key 键 不能为null - * @param item 项 不能为null - * @return 值 - */ - public Object hget(String key, String item) { - return redisTemplate.opsForHash().get(key, item); - } - - - /** - * 获取hashKey对应的所有键值 - * - * @param key 键 - * @return 对应的多个键值 - */ - public Map hmget(String key) { - return redisTemplate.opsForHash().entries(key); - } - - - /** - * HashSet - * - * @param key 键 - * @param map 对应多个键值 - * @return true 成功 false 失败 - */ - public boolean hmset(String key, Map map) { - try { - redisTemplate.opsForHash().putAll(key, map); - return true; - } catch (Exception e) { - log.error(e.getMessage(),e); - return false; - } - } - - - /** - * HashSet 并设置时间 - * - * @param key 键 - * @param map 对应多个键值 - * @param time 时间(秒) - * @return true成功 false失败 - */ - public boolean hmset(String key, Map map, long time) { - try { - redisTemplate.opsForHash().putAll(key, map); - if (time > 0) { - expire(key, time); - } - return true; - } catch (Exception e) { - log.error(e.getMessage(),e); - return false; - } - } - - - /** - * 向一张hash表中放入数据,如果不存在将创建 - * - * @param key 键 - * @param item 项 - * @param value 值 - * @return true 成功 false失败 - */ - public boolean hset(String key, String item, Object value) { - try { - redisTemplate.opsForHash().put(key, item, value); - return true; - } catch (Exception e) { - log.error(e.getMessage(),e); - return false; - } - } - - - /** - * 向一张hash表中放入数据,如果不存在将创建 - * - * @param key 键 - * @param item 项 - * @param value 值 - * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 - * @return true 成功 false失败 - */ - public boolean hset(String key, String item, Object value, long time) { - try { - redisTemplate.opsForHash().put(key, item, value); - if (time > 0) { - expire(key, time); - } - return true; - } catch (Exception e) { - log.error(e.getMessage(),e); - return false; - } - } - - - /** - * 删除hash表中的值 - * - * @param key 键 不能为null - * @param item 项 可以使多个 不能为null - */ - - - public void hdel(String key, Object... item) { - redisTemplate.opsForHash().delete(key, item); - } - - - /** - * 判断hash表中是否有该项的值 - * - * @param key 键 不能为null - * @param item 项 不能为null - * @return true 存在 false不存在 - */ - public boolean hHasKey(String key, String item) { - return redisTemplate.opsForHash().hasKey(key, item); - } - - - /** - * hash递增 如果不存在,就会创建一个 并把新增后的值返回 - * - * @param key 键 - * @param item 项 - * @param by 要增加几(大于0) - * @return - */ - public double hincr(String key, String item, double by) { - return redisTemplate.opsForHash().increment(key, item, by); - } - - - /** - * hash递减 - * - * @param key 键 - * @param item 项 - * @param by 要减少记(小于0) - * @return - */ - public double hdecr(String key, String item, double by) { - return redisTemplate.opsForHash().increment(key, item, -by); - } - - - /** - * 根据key获取Set中的所有值 - * - * @param key 键 - * @return - */ - public Set sGet(String key) { - try { - return redisTemplate.opsForSet().members(key); - } catch (Exception e) { - log.error(e.getMessage(),e); - return null; - } - } - - - /** - * 根据value从一个set中查询,是否存在 - * - * @param key 键 - * @param value 值 - * @return true 存在 false不存在 - */ - public boolean sHasKey(String key, Object value) { - try { - return redisTemplate.opsForSet().isMember(key, value); - } catch (Exception e) { - log.error(e.getMessage(),e); - return false; - } - } - - - /** - * 将数据放入set缓存 - * - * @param key 键 - * @param values 值 可以是多个 - * @return 成功个数 - */ - public long sSet(String key, Object... values) { - try { - return redisTemplate.opsForSet().add(key, values); - } catch (Exception e) { - log.error(e.getMessage(),e); - return 0; - } - } - - - /** - * 将set数据放入缓存 - * - * @param key 键 - * @param time 时间(秒) - * @param values 值 可以是多个 - * @return 成功个数 - */ - public long sSetAndTime(String key, long time, Object... values) { - try { - Long count = redisTemplate.opsForSet().add(key, values); - if (time > 0) - expire(key, time); - return count; - } catch (Exception e) { - log.error(e.getMessage(),e); - return 0; - } - } - - - /** - * 获取set缓存的长度 - * - * @param key 键 - * @return - */ - public long sGetSetSize(String key) { - try { - return redisTemplate.opsForSet().size(key); - } catch (Exception e) { - log.error(e.getMessage(),e); - return 0; - } - } - - - /** - * 移除值为value的 - * - * @param key 键 - * @param values 值 可以是多个 - * @return 移除的个数 - */ - public long setRemove(String key, Object... values) { - try { - Long count = redisTemplate.opsForSet().remove(key, values); - return count; - } catch (Exception e) { - log.error(e.getMessage(),e); - return 0; - } - } - - - /** - * 获取list缓存的内容 - * - * @param key 键 - * @param start 开始 - * @param end 结束 0 到 -代表所有值 - * @return - */ - public List lGet(String key, long start, long end) { - try { - return redisTemplate.opsForList().range(key, start, end); - } catch (Exception e) { - log.error(e.getMessage(),e); - return null; - } - } - - - /** - * 获取list缓存的长度 - * - * @param key 键 - * @return - */ - public long lGetListSize(String key) { - try { - return redisTemplate.opsForList().size(key); - } catch (Exception e) { - log.error(e.getMessage(),e); - return 0; - } - } - - - /** - * 通过索引 获取list中的值 - * - * @param key 键 - * @param index 索引 index>=0时, 0 表头, 第二个元素,依次类推;index<0时,-,表尾,-倒数第二个元素,依次类推 - * @return - */ - public Object lGetIndex(String key, long index) { - try { - return redisTemplate.opsForList().index(key, index); - } catch (Exception e) { - log.error(e.getMessage(),e); - return null; - } - } - - - /** - * 将list放入缓存 - * - * @param key 键 - * @param value 值 - * @return - */ - public boolean lSet(String key, Object value) { - try { - redisTemplate.opsForList().rightPush(key, value); - return true; - } catch (Exception e) { - log.error(e.getMessage(),e); - return false; - } - } - - - /** - * 将list放入缓存 - * - * @param key 键 - * @param value 值 - * @param time 时间(秒) - * @return - */ - public boolean lSet(String key, Object value, long time) { - try { - redisTemplate.opsForList().rightPush(key, value); - if (time > 0) - expire(key, time); - return true; - } catch (Exception e) { - log.error(e.getMessage(),e); - return false; - } - } - - - /** - * 将list放入缓存 - * - * @param key 键 - * @param value 值 - * @return - */ - public boolean lSet(String key, List value) { - try { - redisTemplate.opsForList().rightPushAll(key, value); - return true; - } catch (Exception e) { - log.error(e.getMessage(),e); - return false; - } - } - - - /** - * 将list放入缓存 - * - * @param key 键 - * @param value 值 - * @param time 时间(秒) - * @return - */ - public boolean lSet(String key, List value, long time) { - try { - redisTemplate.opsForList().rightPushAll(key, value); - if (time > 0) - expire(key, time); - return true; - } catch (Exception e) { - log.error(e.getMessage(),e); - return false; - } - } - - - /** - * 根据索引修改list中的某条数据 - * - * @param key 键 - * @param index 索引 - * @param value 值 - * @return - */ - public boolean lUpdateIndex(String key, long index, Object value) { - try { - redisTemplate.opsForList().set(key, index, value); - return true; - } catch (Exception e) { - log.error(e.getMessage(),e); - return false; - } - } - - - /** - * 移除N个值为value - * - * @param key 键 - * @param count 移除多少个 - * @param value 值 - * @return 移除的个数 - */ - public long lRemove(String key, long count, Object value) { - try { - Long remove = redisTemplate.opsForList().remove(key, count, value); - return remove; - } catch (Exception e) { - log.error(e.getMessage(),e); - return 0; - } - } -} \ No newline at end of file diff --git a/novel-admin/src/main/java/com/java2nb/novel/controller/FriendLinkController.java b/novel-admin/src/main/java/com/java2nb/novel/controller/FriendLinkController.java new file mode 100644 index 0000000..a26a40a --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/controller/FriendLinkController.java @@ -0,0 +1,135 @@ +package com.java2nb.novel.controller; + +import com.java2nb.common.config.CacheKey; +import com.java2nb.common.utils.PageBean; +import com.java2nb.common.utils.Query; +import com.java2nb.common.utils.R; +import com.java2nb.novel.domain.FriendLinkDO; +import com.java2nb.novel.service.FriendLinkService; +import io.swagger.annotations.ApiOperation; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +/** + * @author xiongxy + * @email 1179705413@qq.com + * @date 2023-04-14 15:12:25 + */ + +@Controller +@RequestMapping("/novel/friendLink") +public class FriendLinkController { + + @Autowired + private FriendLinkService friendLinkService; + @Autowired + private RedisTemplate redisTemplate; + + @GetMapping() + @RequiresPermissions("novel:friendLink:friendLink") + String FriendLink() { + return "novel/friendLink/friendLink"; + } + + @ApiOperation(value = "获取列表", notes = "获取列表") + @ResponseBody + @GetMapping("/list") + @RequiresPermissions("novel:friendLink:friendLink") + public R list(@RequestParam Map params) { + //查询列表数据 + Query query = new Query(params); + List friendLinkList = friendLinkService.list(query); + int total = friendLinkService.count(query); + PageBean pageBean = new PageBean(friendLinkList, total); + return R.ok().put("data", pageBean); + } + + @ApiOperation(value = "新增页面", notes = "新增页面") + @GetMapping("/add") + @RequiresPermissions("novel:friendLink:add") + String add() { + return "novel/friendLink/add"; + } + + @ApiOperation(value = "修改页面", notes = "修改页面") + @GetMapping("/edit/{id}") + @RequiresPermissions("novel:friendLink:edit") + String edit(@PathVariable("id") Integer id, Model model) { + FriendLinkDO friendLink = friendLinkService.get(id); + model.addAttribute("friendLink", friendLink); + return "novel/friendLink/edit"; + } + + @ApiOperation(value = "查看页面", notes = "查看页面") + @GetMapping("/detail/{id}") + @RequiresPermissions("novel:friendLink:detail") + String detail(@PathVariable("id") Integer id, Model model) { + FriendLinkDO friendLink = friendLinkService.get(id); + model.addAttribute("friendLink", friendLink); + return "novel/friendLink/detail"; + } + + /** + * 保存 + */ + @ApiOperation(value = "新增", notes = "新增") + @ResponseBody + @PostMapping("/save") + @RequiresPermissions("novel:friendLink:add") + public R save(FriendLinkDO friendLink) { + if (friendLinkService.save(friendLink) > 0) { + redisTemplate.delete(CacheKey.INDEX_LINK_KEY); + return R.ok(); + } + return R.error(); + } + + /** + * 修改 + */ + @ApiOperation(value = "修改", notes = "修改") + @ResponseBody + @RequestMapping("/update") + @RequiresPermissions("novel:friendLink:edit") + public R update(FriendLinkDO friendLink) { + friendLinkService.update(friendLink); + redisTemplate.delete(CacheKey.INDEX_LINK_KEY); + return R.ok(); + } + + /** + * 删除 + */ + @ApiOperation(value = "删除", notes = "删除") + @PostMapping("/remove") + @ResponseBody + @RequiresPermissions("novel:friendLink:remove") + public R remove(Integer id) { + if (friendLinkService.remove(id) > 0) { + redisTemplate.delete(CacheKey.INDEX_LINK_KEY); + return R.ok(); + } + return R.error(); + } + + /** + * 删除 + */ + @ApiOperation(value = "批量删除", notes = "批量删除") + @PostMapping("/batchRemove") + @ResponseBody + @RequiresPermissions("novel:friendLink:batchRemove") + public R remove(@RequestParam("ids[]") Integer[] ids) { + friendLinkService.batchRemove(ids); + redisTemplate.delete(CacheKey.INDEX_LINK_KEY); + return R.ok(); + } + +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/dao/FriendLinkDao.java b/novel-admin/src/main/java/com/java2nb/novel/dao/FriendLinkDao.java new file mode 100644 index 0000000..d8b587c --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/dao/FriendLinkDao.java @@ -0,0 +1,32 @@ +package com.java2nb.novel.dao; + +import com.java2nb.novel.domain.FriendLinkDO; + +import java.util.List; +import java.util.Map; + +import org.apache.ibatis.annotations.Mapper; + +/** + * + * @author xiongxy + * @email 1179705413@qq.com + * @date 2023-04-14 15:12:25 + */ +@Mapper +public interface FriendLinkDao { + + FriendLinkDO get(Integer id); + + List list(Map map); + + int count(Map map); + + int save(FriendLinkDO friendLink); + + int update(FriendLinkDO friendLink); + + int remove(Integer id); + + int batchRemove(Integer[] ids); +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/domain/FriendLinkDO.java b/novel-admin/src/main/java/com/java2nb/novel/domain/FriendLinkDO.java new file mode 100644 index 0000000..b0b9d73 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/domain/FriendLinkDO.java @@ -0,0 +1,163 @@ +package com.java2nb.novel.domain; + +import java.io.Serializable; + + +import java.math.BigDecimal; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.java2nb.common.jsonserializer.LongToStringSerializer; + + +import org.springframework.format.annotation.DateTimeFormat; +import java.util.Date; + + + +/** + * + * + * @author xiongxy + * @email 1179705413@qq.com + * @date 2023-04-14 15:12:25 + */ +public class FriendLinkDO implements Serializable { + private static final long serialVersionUID = 1L; + + + //主键 + private Integer id; + //链接名 + private String linkName; + //链接url + private String linkUrl; + //排序号 + private Integer sort; + //是否开启,0:不开启,1:开启 + private Integer isOpen; + //创建人id + //java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值) + //所以通过序列化成字符串来解决 + @JsonSerialize(using = LongToStringSerializer.class) + private Long createUserId; + //创建时间 + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + //更新者用户id + //java中的long能表示的范围比js中number大,也就意味着部分数值在js中存不下(变成不准确的值) + //所以通过序列化成字符串来解决 + @JsonSerialize(using = LongToStringSerializer.class) + private Long updateUserId; + //更新时间 + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updateTime; + + /** + * 设置:主键 + */ + public void setId(Integer id) { + this.id = id; + } + /** + * 获取:主键 + */ + public Integer getId() { + return id; + } + /** + * 设置:链接名 + */ + public void setLinkName(String linkName) { + this.linkName = linkName; + } + /** + * 获取:链接名 + */ + public String getLinkName() { + return linkName; + } + /** + * 设置:链接url + */ + public void setLinkUrl(String linkUrl) { + this.linkUrl = linkUrl; + } + /** + * 获取:链接url + */ + public String getLinkUrl() { + return linkUrl; + } + /** + * 设置:排序号 + */ + public void setSort(Integer sort) { + this.sort = sort; + } + /** + * 获取:排序号 + */ + public Integer getSort() { + return sort; + } + /** + * 设置:是否开启,0:不开启,1:开启 + */ + public void setIsOpen(Integer isOpen) { + this.isOpen = isOpen; + } + /** + * 获取:是否开启,0:不开启,1:开启 + */ + public Integer getIsOpen() { + return isOpen; + } + /** + * 设置:创建人id + */ + public void setCreateUserId(Long createUserId) { + this.createUserId = createUserId; + } + /** + * 获取:创建人id + */ + public Long getCreateUserId() { + return createUserId; + } + /** + * 设置:创建时间 + */ + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + /** + * 获取:创建时间 + */ + public Date getCreateTime() { + return createTime; + } + /** + * 设置:更新者用户id + */ + public void setUpdateUserId(Long updateUserId) { + this.updateUserId = updateUserId; + } + /** + * 获取:更新者用户id + */ + public Long getUpdateUserId() { + return updateUserId; + } + /** + * 设置:更新时间 + */ + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + /** + * 获取:更新时间 + */ + public Date getUpdateTime() { + return updateTime; + } +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/service/FriendLinkService.java b/novel-admin/src/main/java/com/java2nb/novel/service/FriendLinkService.java new file mode 100644 index 0000000..4389936 --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/service/FriendLinkService.java @@ -0,0 +1,30 @@ +package com.java2nb.novel.service; + +import com.java2nb.novel.domain.FriendLinkDO; + +import java.util.List; +import java.util.Map; + +/** + * + * + * @author xiongxy + * @email 1179705413@qq.com + * @date 2023-04-14 15:12:25 + */ +public interface FriendLinkService { + + FriendLinkDO get(Integer id); + + List list(Map map); + + int count(Map map); + + int save(FriendLinkDO friendLink); + + int update(FriendLinkDO friendLink); + + int remove(Integer id); + + int batchRemove(Integer[] ids); +} diff --git a/novel-admin/src/main/java/com/java2nb/novel/service/impl/FriendLinkServiceImpl.java b/novel-admin/src/main/java/com/java2nb/novel/service/impl/FriendLinkServiceImpl.java new file mode 100644 index 0000000..f79a49a --- /dev/null +++ b/novel-admin/src/main/java/com/java2nb/novel/service/impl/FriendLinkServiceImpl.java @@ -0,0 +1,55 @@ +package com.java2nb.novel.service.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +import com.java2nb.novel.dao.FriendLinkDao; +import com.java2nb.novel.domain.FriendLinkDO; +import com.java2nb.novel.service.FriendLinkService; + + + +@Service +public class FriendLinkServiceImpl implements FriendLinkService { + @Autowired + private FriendLinkDao friendLinkDao; + + @Override + public FriendLinkDO get(Integer id){ + return friendLinkDao.get(id); + } + + @Override + public List list(Map map){ + return friendLinkDao.list(map); + } + + @Override + public int count(Map map){ + return friendLinkDao.count(map); + } + + @Override + public int save(FriendLinkDO friendLink){ + return friendLinkDao.save(friendLink); + } + + @Override + public int update(FriendLinkDO friendLink){ + return friendLinkDao.update(friendLink); + } + + @Override + public int remove(Integer id){ + return friendLinkDao.remove(id); + } + + @Override + public int batchRemove(Integer[] ids){ + return friendLinkDao.batchRemove(ids); + } + +} diff --git a/novel-admin/src/main/java/com/java2nb/system/controller/SysUserController.java b/novel-admin/src/main/java/com/java2nb/system/controller/SysUserController.java index 8ca31f7..1423ad1 100644 --- a/novel-admin/src/main/java/com/java2nb/system/controller/SysUserController.java +++ b/novel-admin/src/main/java/com/java2nb/system/controller/SysUserController.java @@ -5,15 +5,16 @@ import com.java2nb.common.config.Constant; import com.java2nb.common.controller.BaseController; import com.java2nb.common.domain.Tree; import com.java2nb.common.service.DictService; -import com.java2nb.common.utils.*; +import com.java2nb.common.utils.MD5Utils; +import com.java2nb.common.utils.PageBean; +import com.java2nb.common.utils.Query; +import com.java2nb.common.utils.R; import com.java2nb.system.domain.DeptDO; import com.java2nb.system.domain.RoleDO; import com.java2nb.system.domain.UserDO; import com.java2nb.system.service.RoleService; import com.java2nb.system.service.SysUserService; import com.java2nb.system.vo.UserVO; -import javax.servlet.http.HttpServletRequest; - import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -21,6 +22,7 @@ import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -28,217 +30,219 @@ import java.util.Map; @RequestMapping("/sys/user") @Controller public class SysUserController extends BaseController { - private String prefix="system/user" ; - @Autowired - SysUserService userService; - @Autowired - RoleService roleService; - @Autowired - DictService dictService; - @Autowired - RedisUtil redisUtil; - @RequiresPermissions("sys:user:user") - @GetMapping("") - String user(Model model) { - return prefix + "/user"; - } + private String prefix = "system/user"; + @Autowired + SysUserService userService; + @Autowired + RoleService roleService; + @Autowired + DictService dictService; - @GetMapping("/list") - @ResponseBody - PageBean list(@RequestParam Map params) { - // 查询列表数据 - Query query = new Query(params); - List sysUserList = userService.list(query); - int total = userService.count(query); - PageBean pageUtil = new PageBean(sysUserList, total); - return pageUtil; - } + @RequiresPermissions("sys:user:user") + @GetMapping("") + String user(Model model) { + return prefix + "/user"; + } - @RequiresPermissions("sys:user:add") - @Log("添加用户") - @GetMapping("/add") - String add(Model model) { - List roles = roleService.list(); - model.addAttribute("roles", roles); - return prefix + "/add"; - } + @GetMapping("/list") + @ResponseBody + PageBean list(@RequestParam Map params) { + // 查询列表数据 + Query query = new Query(params); + List sysUserList = userService.list(query); + int total = userService.count(query); + PageBean pageUtil = new PageBean(sysUserList, total); + return pageUtil; + } - @RequiresPermissions("sys:user:edit") - @Log("编辑用户") - @GetMapping("/edit/{id}") - String edit(Model model, @PathVariable("id") Long id) { - UserDO userDO = userService.get(id); - model.addAttribute("user", userDO); - List roles = roleService.list(id); - model.addAttribute("roles", roles); - return prefix+"/edit"; - } + @RequiresPermissions("sys:user:add") + @Log("添加用户") + @GetMapping("/add") + String add(Model model) { + List roles = roleService.list(); + model.addAttribute("roles", roles); + return prefix + "/add"; + } - public static void main(String[] args) { - System.out.println(MD5Utils.encrypt("admin", "admin")); - } + @RequiresPermissions("sys:user:edit") + @Log("编辑用户") + @GetMapping("/edit/{id}") + String edit(Model model, @PathVariable("id") Long id) { + UserDO userDO = userService.get(id); + model.addAttribute("user", userDO); + List roles = roleService.list(id); + model.addAttribute("roles", roles); + return prefix + "/edit"; + } - @RequiresPermissions("sys:user:add") - @Log("保存用户") - @PostMapping("/save") - @ResponseBody - R save(UserDO user) { - if (Constant.DEMO_ACCOUNT.equals(getUsername())) { - return R.error(1, "演示系统不允许修改,完整体验请部署程序"); - } - user.setPassword(MD5Utils.encrypt(user.getUsername(), user.getPassword())); - if (userService.save(user) > 0) { - return R.ok(); - } - return R.error(); - } + public static void main(String[] args) { + System.out.println(MD5Utils.encrypt("admin", "admin")); + } - @RequiresPermissions("sys:user:edit") - @Log("更新用户") - @PostMapping("/update") - @ResponseBody - R update(UserDO user) { - if (Constant.DEMO_ACCOUNT.equals(getUsername())) { - return R.error(1, "演示系统不允许修改,完整体验请部署程序"); - } - if (userService.update(user) > 0) { - return R.ok(); - } - return R.error(); - } + @RequiresPermissions("sys:user:add") + @Log("保存用户") + @PostMapping("/save") + @ResponseBody + R save(UserDO user) { + if (Constant.DEMO_ACCOUNT.equals(getUsername())) { + return R.error(1, "演示系统不允许修改,完整体验请部署程序"); + } + user.setPassword(MD5Utils.encrypt(user.getUsername(), user.getPassword())); + if (userService.save(user) > 0) { + return R.ok(); + } + return R.error(); + } + + @RequiresPermissions("sys:user:edit") + @Log("更新用户") + @PostMapping("/update") + @ResponseBody + R update(UserDO user) { + if (Constant.DEMO_ACCOUNT.equals(getUsername())) { + return R.error(1, "演示系统不允许修改,完整体验请部署程序"); + } + if (userService.update(user) > 0) { + return R.ok(); + } + return R.error(); + } - @RequiresPermissions("sys:user:edit") - @Log("更新用户") - @PostMapping("/updatePeronal") - @ResponseBody - R updatePeronal(UserDO user) { - if (Constant.DEMO_ACCOUNT.equals(getUsername())) { - return R.error(1, "演示系统不允许修改,完整体验请部署程序"); - } - if (userService.updatePersonal(user) > 0) { - return R.ok(); - } - return R.error(); - } + @RequiresPermissions("sys:user:edit") + @Log("更新用户") + @PostMapping("/updatePeronal") + @ResponseBody + R updatePeronal(UserDO user) { + if (Constant.DEMO_ACCOUNT.equals(getUsername())) { + return R.error(1, "演示系统不允许修改,完整体验请部署程序"); + } + if (userService.updatePersonal(user) > 0) { + return R.ok(); + } + return R.error(); + } - @RequiresPermissions("sys:user:remove") - @Log("删除用户") - @PostMapping("/remove") - @ResponseBody - R remove(Long id) { - if (Constant.DEMO_ACCOUNT.equals(getUsername())) { - return R.error(1, "演示系统不允许修改,完整体验请部署程序"); - } - if (userService.remove(id) > 0) { - return R.ok(); - } - return R.error(); - } + @RequiresPermissions("sys:user:remove") + @Log("删除用户") + @PostMapping("/remove") + @ResponseBody + R remove(Long id) { + if (Constant.DEMO_ACCOUNT.equals(getUsername())) { + return R.error(1, "演示系统不允许修改,完整体验请部署程序"); + } + if (userService.remove(id) > 0) { + return R.ok(); + } + return R.error(); + } - @RequiresPermissions("sys:user:batchRemove") - @Log("批量删除用户") - @PostMapping("/batchRemove") - @ResponseBody - R batchRemove(@RequestParam("ids[]") Long[] userIds) { - if (Constant.DEMO_ACCOUNT.equals(getUsername())) { - return R.error(1, "演示系统不允许修改,完整体验请部署程序"); - } - int r = userService.batchremove(userIds); - if (r > 0) { - return R.ok(); - } - return R.error(); - } + @RequiresPermissions("sys:user:batchRemove") + @Log("批量删除用户") + @PostMapping("/batchRemove") + @ResponseBody + R batchRemove(@RequestParam("ids[]") Long[] userIds) { + if (Constant.DEMO_ACCOUNT.equals(getUsername())) { + return R.error(1, "演示系统不允许修改,完整体验请部署程序"); + } + int r = userService.batchremove(userIds); + if (r > 0) { + return R.ok(); + } + return R.error(); + } - @PostMapping("/exit") - @ResponseBody - boolean exit(@RequestParam Map params) { - // 存在,不通过,false - return !userService.exit(params); - } + @PostMapping("/exit") + @ResponseBody + boolean exit(@RequestParam Map params) { + // 存在,不通过,false + return !userService.exit(params); + } - @RequiresPermissions("sys:user:resetPwd") - @Log("请求更改用户密码") - @GetMapping("/resetPwd/{id}") - String resetPwd(@PathVariable("id") Long userId, Model model) { + @RequiresPermissions("sys:user:resetPwd") + @Log("请求更改用户密码") + @GetMapping("/resetPwd/{id}") + String resetPwd(@PathVariable("id") Long userId, Model model) { - UserDO userDO = new UserDO(); - userDO.setUserId(userId); - model.addAttribute("user", userDO); - return prefix + "/reset_pwd"; - } + UserDO userDO = new UserDO(); + userDO.setUserId(userId); + model.addAttribute("user", userDO); + return prefix + "/reset_pwd"; + } - @Log("提交更改用户密码") - @PostMapping("/resetPwd") - @ResponseBody - R resetPwd(UserVO userVO) { - if (Constant.DEMO_ACCOUNT.equals(getUsername())) { - return R.error(1, "演示系统不允许修改,完整体验请部署程序"); - } - try{ - userService.resetPwd(userVO,getUser()); - return R.ok(); - }catch (Exception e){ - return R.error(1,e.getMessage()); - } + @Log("提交更改用户密码") + @PostMapping("/resetPwd") + @ResponseBody + R resetPwd(UserVO userVO) { + if (Constant.DEMO_ACCOUNT.equals(getUsername())) { + return R.error(1, "演示系统不允许修改,完整体验请部署程序"); + } + try { + userService.resetPwd(userVO, getUser()); + return R.ok(); + } catch (Exception e) { + return R.error(1, e.getMessage()); + } - } - @RequiresPermissions("sys:user:resetPwd") - @Log("admin提交更改用户密码") - @PostMapping("/adminResetPwd") - @ResponseBody - R adminResetPwd(UserVO userVO) { - if (Constant.DEMO_ACCOUNT.equals(getUsername())) { - return R.error(1, "演示系统不允许修改,完整体验请部署程序"); - } - try{ - userService.adminResetPwd(userVO); - return R.ok(); - }catch (Exception e){ - return R.error(1,e.getMessage()); - } + } - } - @GetMapping("/tree") - @ResponseBody - public Tree tree() { - Tree tree = new Tree(); - tree = userService.getTree(); - return tree; - } + @RequiresPermissions("sys:user:resetPwd") + @Log("admin提交更改用户密码") + @PostMapping("/adminResetPwd") + @ResponseBody + R adminResetPwd(UserVO userVO) { + if (Constant.DEMO_ACCOUNT.equals(getUsername())) { + return R.error(1, "演示系统不允许修改,完整体验请部署程序"); + } + try { + userService.adminResetPwd(userVO); + return R.ok(); + } catch (Exception e) { + return R.error(1, e.getMessage()); + } - @GetMapping("/treeView") - String treeView() { - return prefix + "/userTree"; - } + } - @GetMapping("/personal") - String personal(Model model) { - UserDO userDO = userService.get(getUserId()); - model.addAttribute("user",userDO); - model.addAttribute("hobbyList",dictService.getHobbyList(userDO)); - model.addAttribute("sexList",dictService.getSexList()); - return prefix + "/personal"; - } - @ResponseBody - @PostMapping("/uploadImg") - R uploadImg(@RequestParam("avatar_file") MultipartFile file, String avatar_data, HttpServletRequest request) { - if ("test".equals(getUsername())) { - return R.error(1, "演示系统不允许修改,完整体验请部署程序"); - } - Map result = new HashMap<>(); - try { - result = userService.updatePersonalImg(file, avatar_data, getUserId()); - } catch (Exception e) { - return R.error("更新图像失败!"); - } - if(result!=null && result.size()>0){ - return R.ok(result); - }else { - return R.error("更新图像失败!"); - } - } + @GetMapping("/tree") + @ResponseBody + public Tree tree() { + Tree tree = new Tree(); + tree = userService.getTree(); + return tree; + } + + @GetMapping("/treeView") + String treeView() { + return prefix + "/userTree"; + } + + @GetMapping("/personal") + String personal(Model model) { + UserDO userDO = userService.get(getUserId()); + model.addAttribute("user", userDO); + model.addAttribute("hobbyList", dictService.getHobbyList(userDO)); + model.addAttribute("sexList", dictService.getSexList()); + return prefix + "/personal"; + } + + @ResponseBody + @PostMapping("/uploadImg") + R uploadImg(@RequestParam("avatar_file") MultipartFile file, String avatar_data, HttpServletRequest request) { + if ("test".equals(getUsername())) { + return R.error(1, "演示系统不允许修改,完整体验请部署程序"); + } + Map result = new HashMap<>(); + try { + result = userService.updatePersonalImg(file, avatar_data, getUserId()); + } catch (Exception e) { + return R.error("更新图像失败!"); + } + if (result != null && result.size() > 0) { + return R.ok(result); + } else { + return R.error("更新图像失败!"); + } + } } diff --git a/novel-admin/src/main/resources/mybatis/novel/FriendLinkMapper.xml b/novel-admin/src/main/resources/mybatis/novel/FriendLinkMapper.xml new file mode 100644 index 0000000..aca48d0 --- /dev/null +++ b/novel-admin/src/main/resources/mybatis/novel/FriendLinkMapper.xml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + insert into friend_link + ( + `id`, + `link_name`, + `link_url`, + `sort`, + `is_open`, + `create_user_id`, + `create_time`, + `update_user_id`, + `update_time` + ) + values + ( + #{id}, + #{linkName}, + #{linkUrl}, + #{sort}, + #{isOpen}, + #{createUserId}, + #{createTime}, + #{updateUserId}, + #{updateTime} + ) + + + + insert into friend_link + ( + `id`, + `link_name`, + `link_url`, + `sort`, + `is_open`, + `create_user_id`, + `create_time`, + `update_user_id`, + `update_time` + ) + values + ( + #{id}, + #{linkName}, + #{linkUrl}, + #{sort}, + #{isOpen}, + #{createUserId}, + #{createTime}, + #{updateUserId}, + #{updateTime} + ) + + + + update friend_link + + `link_name` = #{linkName}, + `link_url` = #{linkUrl}, + `sort` = #{sort}, + `is_open` = #{isOpen}, + `create_user_id` = #{createUserId}, + `create_time` = #{createTime}, + `update_user_id` = #{updateUserId}, + `update_time` = #{updateTime} + + where id = #{id} + + + + delete from friend_link where id = #{value} + + + + delete from friend_link where id in + + #{id} + + + + \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/friendLink/add.js b/novel-admin/src/main/resources/static/js/appjs/novel/friendLink/add.js new file mode 100644 index 0000000..145b3ca --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/friendLink/add.js @@ -0,0 +1,107 @@ +var E = window.wangEditor; +$("[id^='contentEditor']").each(function (index, ele) { + var relName = $(ele).attr("id").substring(13); + var editor = new E('#contentEditor' + relName); +// 自定义菜单配置 + editor.customConfig.menus = [ + 'head', // 标题 + 'bold', // 粗体 + 'fontSize', // 字号 + 'fontName', // 字体 + 'italic', // 斜体 + 'underline', // 下划线 + 'strikeThrough', // 删除线 + 'foreColor', // 文字颜色 + //'backColor', // 背景颜色 + //'link', // 插入链接 + 'list', // 列表 + 'justify', // 对齐方式 + 'quote', // 引用 + 'emoticon', // 表情 + 'image', // 插入图片 + //'table', // 表格 + //'video', // 插入视频 + //'code', // 插入代码 + 'undo', // 撤销 + 'redo' // 重复 + ]; + editor.customConfig.onchange = function (html) { + // html 即变化之后的内容 + $("#" + relName).val(html); + } + editor.customConfig.uploadImgShowBase64 = true; + editor.create(); + +}) + +$("[id^='picImage']").each(function (index, ele) { + var relName = $(ele).attr("id").substring(8); + layui.use('upload', function () { + var upload = layui.upload; + //执行实例 + var uploadInst = upload.render({ + elem: '#picImage' + relName, //绑定元素 + url: '/common/sysFile/upload', //上传接口 + size: 1000, + accept: 'file', + done: function (r) { + $("#picImage" + relName).attr("src", r.fileName); + $("#" + relName).val(r.fileName); + }, + error: function (r) { + layer.msg(r.msg); + } + }); + }); + +}); + + + + + + +$().ready(function () { + validateRule(); +}); + +$.validator.setDefaults({ + submitHandler: function () { + save(); + } +}); +function save() { + $.ajax({ + cache: true, + type: "POST", + url: "/novel/friendLink/save", + data: $('#signupForm').serialize(),// 你的formid + async: false, + error: function (request) { + parent.layer.alert("Connection error"); + }, + success: function (data) { + if (data.code == 0) { + parent.layer.msg("操作成功"); + parent.reLoad(); + var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引 + parent.layer.close(index); + + } else { + parent.layer.alert(data.msg) + } + + } + }); + +} +function validateRule() { + var icon = " "; + $("#signupForm").validate({ + ignore: "", + rules: { + }, + messages: { + } +}) +} \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/friendLink/edit.js b/novel-admin/src/main/resources/static/js/appjs/novel/friendLink/edit.js new file mode 100644 index 0000000..39412a1 --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/friendLink/edit.js @@ -0,0 +1,103 @@ +var E = window.wangEditor; +$("[id^='contentEditor']").each(function (index, ele) { + var relName = $(ele).attr("id").substring(13); + var editor = new E('#contentEditor' + relName); +// 自定义菜单配置 + editor.customConfig.menus = [ + 'head', // 标题 + 'bold', // 粗体 + 'fontSize', // 字号 + 'fontName', // 字体 + 'italic', // 斜体 + 'underline', // 下划线 + 'strikeThrough', // 删除线 + 'foreColor', // 文字颜色 + //'backColor', // 背景颜色 + //'link', // 插入链接 + 'list', // 列表 + 'justify', // 对齐方式 + 'quote', // 引用 + 'emoticon', // 表情 + 'image', // 插入图片 + //'table', // 表格 + //'video', // 插入视频 + //'code', // 插入代码 + 'undo', // 撤销 + 'redo' // 重复 + ]; + editor.customConfig.onchange = function (html) { + // html 即变化之后的内容 + $("#" + relName).val(html); + } + editor.customConfig.uploadImgShowBase64 = true; + editor.create(); + editor.txt.html($("#" + relName).val()); + +}) + +$("[id^='picImage']").each(function (index, ele) { + var relName = $(ele).attr("id").substring(8); + layui.use('upload', function () { + var upload = layui.upload; + //执行实例 + var uploadInst = upload.render({ + elem: '#picImage' + relName, //绑定元素 + url: '/common/sysFile/upload', //上传接口 + size: 1000, + accept: 'file', + done: function (r) { + $("#picImage" + relName).attr("src", r.fileName); + $("#" + relName).val(r.fileName); + }, + error: function (r) { + layer.msg(r.msg); + } + }); + }); + +}); + +$().ready(function () { + validateRule(); +}); + +$.validator.setDefaults({ + submitHandler: function () { + update(); + } +}); +function update() { + $.ajax({ + cache: true, + type: "POST", + url: "/novel/friendLink/update", + data: $('#signupForm').serialize(),// 你的formid + async: false, + error: function (request) { + parent.layer.alert("Connection error"); + }, + success: function (data) { + if (data.code == 0) { + parent.layer.msg("操作成功"); + parent.reLoad(); + var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引 + parent.layer.close(index); + + } else { + parent.layer.alert(data.msg) + } + + } + }); + +} +function validateRule() { + var icon = " "; + $("#signupForm").validate({ + ignore: "", + rules: { + }, + messages: { + } +}) +} \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/js/appjs/novel/friendLink/friendLink.js b/novel-admin/src/main/resources/static/js/appjs/novel/friendLink/friendLink.js new file mode 100644 index 0000000..06c6078 --- /dev/null +++ b/novel-admin/src/main/resources/static/js/appjs/novel/friendLink/friendLink.js @@ -0,0 +1,205 @@ +var prefix = "/novel/friendLink" +$(function () { + load(); +}); + +function load() { + $('#exampleTable') + .bootstrapTable( + { + method: 'get', // 服务器数据的请求方式 get or post + url: prefix + "/list", // 服务器数据的加载地址 + // showRefresh : true, + // showToggle : true, + // showColumns : true, + iconSize: 'outline', + toolbar: '#exampleToolbar', + striped: true, // 设置为true会有隔行变色效果 + dataType: "json", // 服务器返回的数据类型 + pagination: true, // 设置为true会在底部显示分页条 + // queryParamsType : "limit", + // //设置为limit则会发送符合RESTFull格式的参数 + singleSelect: false, // 设置为true将禁止多选 + // contentType : "application/x-www-form-urlencoded", + // //发送到服务器的数据编码类型 + pageSize: 10, // 如果设置了分页,每页数据条数 + pageNumber: 1, // 如果设置了分布,首页页码 + //search : true, // 是否显示搜索框 + showColumns: false, // 是否显示内容下拉框(选择显示的列) + sidePagination: "server", // 设置在哪里进行分页,可选值为"client" 或者 "server" + queryParams: function (params) { + //说明:传入后台的参数包括offset开始索引,limit步长,sort排序列,order:desc或者,以及所有列的键值对 + var queryParams = getFormJson("searchForm"); + queryParams.limit = params.limit; + queryParams.offset = params.offset; + return queryParams; + }, + // //请求服务器数据时,你可以通过重写参数的方式添加一些额外的参数,例如 toolbar 中的参数 如果 + // queryParamsType = 'limit' ,返回参数必须包含 + // limit, offset, search, sort, order 否则, 需要包含: + // pageSize, pageNumber, searchText, sortName, + // sortOrder. + // 返回false将会终止请求 + responseHandler: function (rs) { + + if (rs.code == 0) { + return rs.data; + } else { + parent.layer.alert(rs.msg) + return {total: 0, rows: []}; + } + }, + columns: [ + { + checkbox: true + }, + { + title: '序号', + formatter: function () { + return arguments[2] + 1; + } + }, + + { + field: 'linkName', + title: '链接名' + }, + + + { + field: 'linkUrl', + title: '链接url' + }, + + + { + field: 'sort', + title: '排序号' + }, + + + { + field: 'isOpen', + title: '是否开启', + formatter: function (value, row, index) { + return formatDict("yes_no", value); + } + }, + + + { + title: '操作', + field: 'id', + align: 'center', + formatter: function (value, row, index) { + var d = ' '; + var e = ' '; + var r = ' '; + return d + e + r; + } + }] + }); +} + +function reLoad() { + $('#exampleTable').bootstrapTable('refresh'); +} + +function add() { + layer.open({ + type: 2, + title: '增加', + maxmin: true, + shadeClose: false, // 点击遮罩关闭层 + area: ['800px', '520px'], + content: prefix + '/add' // iframe的url + }); +} + +function detail(id) { + layer.open({ + type: 2, + title: '详情', + maxmin: true, + shadeClose: false, // 点击遮罩关闭层 + area: ['800px', '520px'], + content: prefix + '/detail/' + id // iframe的url + }); +} + +function edit(id) { + layer.open({ + type: 2, + title: '编辑', + maxmin: true, + shadeClose: false, // 点击遮罩关闭层 + area: ['800px', '520px'], + content: prefix + '/edit/' + id // iframe的url + }); +} + +function remove(id) { + layer.confirm('确定要删除选中的记录?', { + btn: ['确定', '取消'] + }, function () { + $.ajax({ + url: prefix + "/remove", + type: "post", + data: { + 'id': id + }, + success: function (r) { + if (r.code == 0) { + layer.msg(r.msg); + reLoad(); + } else { + layer.msg(r.msg); + } + } + }); + }) +} + +function resetPwd(id) { +} + +function batchRemove() { + var rows = $('#exampleTable').bootstrapTable('getSelections'); // 返回所有选择的行,当没有选择的记录时,返回一个空数组 + if (rows.length == 0) { + layer.msg("请选择要删除的数据"); + return; + } + layer.confirm("确认要删除选中的'" + rows.length + "'条数据吗?", { + btn: ['确定', '取消'] + // 按钮 + }, function () { + var ids = new Array(); + // 遍历所有选择的行数据,取每条数据对应的ID + $.each(rows, function (i, row) { + ids[i] = row['id']; + }); + $.ajax({ + type: 'POST', + data: { + "ids": ids + }, + url: prefix + '/batchRemove', + success: function (r) { + if (r.code == 0) { + layer.msg(r.msg); + reLoad(); + } else { + layer.msg(r.msg); + } + } + }); + }, function () { + + }); +} \ No newline at end of file diff --git a/novel-admin/src/main/resources/static/sql/novel/friendLink/menu.js b/novel-admin/src/main/resources/static/sql/novel/friendLink/menu.js new file mode 100644 index 0000000..bde8d49 --- /dev/null +++ b/novel-admin/src/main/resources/static/sql/novel/friendLink/menu.js @@ -0,0 +1,18 @@ +-- 菜单SQL +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + VALUES ('1', '', 'novel/friendLink', 'novel:friendLink:friendLink', '1', 'fa', '6'); + +-- 按钮父菜单ID +set @parentId = @@identity; + +-- 菜单对应按钮SQL +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '查看', null, 'novel:friendLink:detail', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '新增', null, 'novel:friendLink:add', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '修改', null, 'novel:friendLink:edit', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '删除', null, 'novel:friendLink:remove', '2', null, '6'; +INSERT INTO `sys_menu` (`parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) + SELECT @parentId, '批量删除', null, 'novel:friendLink:batchRemove', '2', null, '6'; diff --git a/novel-admin/src/main/resources/templates/novel/friendLink/add.html b/novel-admin/src/main/resources/templates/novel/friendLink/add.html new file mode 100644 index 0000000..66e3d11 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/friendLink/add.html @@ -0,0 +1,67 @@ + + + + + +
+
+
+
+
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ +
+ + + +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ + + + diff --git a/novel-admin/src/main/resources/templates/novel/friendLink/detail.html b/novel-admin/src/main/resources/templates/novel/friendLink/detail.html new file mode 100644 index 0000000..adb9972 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/friendLink/detail.html @@ -0,0 +1,100 @@ + + + + + +
+
+
+
+
+
+ +
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+
+ + +
+
+ + +
+
+
+
+
+
+
+
+ + diff --git a/novel-admin/src/main/resources/templates/novel/friendLink/edit.html b/novel-admin/src/main/resources/templates/novel/friendLink/edit.html new file mode 100644 index 0000000..cef908d --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/friendLink/edit.html @@ -0,0 +1,69 @@ + + + + + +
+
+
+
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + +
+
+
+
+ +
+
+
+
+
+
+
+
+
+ + + + diff --git a/novel-admin/src/main/resources/templates/novel/friendLink/friendLink.html b/novel-admin/src/main/resources/templates/novel/friendLink/friendLink.html new file mode 100644 index 0000000..6511fd8 --- /dev/null +++ b/novel-admin/src/main/resources/templates/novel/friendLink/friendLink.html @@ -0,0 +1,59 @@ + + + + + +
+
+
+
+
+
+ + +
+
+ +
+ +
+ +
+
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+ +
+
+ + + \ No newline at end of file