From 2ddbd99aa5b2e396f96c6daba60fe1ac2573d9fb Mon Sep 17 00:00:00 2001 From: inleft <inleft@qq.com> Date: Sat, 18 May 2024 11:53:54 +0800 Subject: [PATCH] 新增RSS 订阅链接 --- snowy-main/src/main/java/vip/xiaonuo/modular/blogfriendshiplink/controller/BlogLinkOutsideController.java | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 53 insertions(+), 5 deletions(-) diff --git a/snowy-main/src/main/java/vip/xiaonuo/modular/blogfriendshiplink/controller/BlogLinkOutsideController.java b/snowy-main/src/main/java/vip/xiaonuo/modular/blogfriendshiplink/controller/BlogLinkOutsideController.java index 78f8d64..1e07422 100644 --- a/snowy-main/src/main/java/vip/xiaonuo/modular/blogfriendshiplink/controller/BlogLinkOutsideController.java +++ b/snowy-main/src/main/java/vip/xiaonuo/modular/blogfriendshiplink/controller/BlogLinkOutsideController.java @@ -26,18 +26,19 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.lang.Dict; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; import vip.xiaonuo.core.annotion.BusinessLog; import vip.xiaonuo.core.consts.CommonConstant; import vip.xiaonuo.core.consts.MyConstant; import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum; +import vip.xiaonuo.core.exception.BlogException; import vip.xiaonuo.core.pojo.response.ResponseData; import vip.xiaonuo.core.pojo.response.SuccessResponseData; import vip.xiaonuo.modular.blogfriendshiplink.entity.BlogFriendshipLink; +import vip.xiaonuo.modular.blogfriendshiplink.entity.BlogLinkVo; +import vip.xiaonuo.modular.blogfriendshiplink.param.BlogFriendshipLinkParam; import vip.xiaonuo.modular.blogfriendshiplink.param.BlogFriendshipLinkVo; -import vip.xiaonuo.modular.blogfriendshiplink.param.BlogLinkVo; import vip.xiaonuo.modular.blogfriendshiplink.service.BlogFriendshipLinkService; import vip.xiaonuo.sys.modular.dict.param.SysDictTypeParam; import vip.xiaonuo.sys.modular.dict.service.SysDictTypeService; @@ -67,6 +68,7 @@ @Resource private SysDictTypeService sysDictTypeService; + /** * 查询blog友情链接 * @@ -78,7 +80,7 @@ public ResponseData queryBlogLinkGroup() { List<BlogFriendshipLink> linkList = blogFriendshipLinkService.lambdaQuery() - .eq(BlogFriendshipLink::getIsEnable,MyConstant.Yes) + .eq(BlogFriendshipLink::getIsEnable, MyConstant.Yes) .orderByAsc(BlogFriendshipLink::getTopValue) .orderByAsc(BlogFriendshipLink::getName) .list(); @@ -109,4 +111,50 @@ return new SuccessResponseData(res); } + + + /** + * 添加友情链接 + * + * @author inleft + * @date 2022-02-17 15:05:44 + */ + @PostMapping("/blogLink/add") + @BusinessLog(title = "外部blog系统_blog友情链接_增加", opType = LogAnnotionOpTypeEnum.ADD) + public ResponseData add(@RequestBody @Validated(BlogFriendshipLinkParam.add.class) BlogFriendshipLinkParam blogFriendshipLinkParam) { + + if (blogFriendshipLinkService.lambdaQuery() + .eq(BlogFriendshipLink::getUrl, blogFriendshipLinkParam.getUrl()) + .count() > 0) { + throw new BlogException("已经有该链接的记录啦,不要重复提交哦.."); + } + + blogFriendshipLinkParam.setIsEnable(MyConstant.Yes); + blogFriendshipLinkService.add(blogFriendshipLinkParam); + return new SuccessResponseData(); + } + + + @GetMapping("/blogLink/getLinkType") + @BusinessLog(title = "外部blog系统_blog友情链接_获取链接类型", opType = LogAnnotionOpTypeEnum.QUERY) + public ResponseData getLinkType() { + + + SysDictTypeParam param = new SysDictTypeParam(); + param.setCode("blog_link_type"); + param.setStatus(MyConstant.No); + List<Dict> dictList = sysDictTypeService.dropDown(param); + + List<BlogLinkVo> res = new ArrayList<>(dictList.size()); + BlogLinkVo vo; + + for (Dict dict : dictList) { + vo = new BlogLinkVo(); + vo.setGroupName(dict.get(CommonConstant.VALUE).toString()); + vo.setLinkTypeId(dict.getLong(CommonConstant.CODE)); + res.add(vo); + } + return new SuccessResponseData(res); + } + } -- Gitblit v1.9.1