commit | author | age
|
4d51af
|
1 |
/* |
I |
2 |
Copyright [2020] [https://www.xiaonuo.vip] |
|
3 |
|
|
4 |
Licensed under the Apache License, Version 2.0 (the "License"); |
|
5 |
you may not use this file except in compliance with the License. |
|
6 |
You may obtain a copy of the License at |
|
7 |
|
|
8 |
http://www.apache.org/licenses/LICENSE-2.0 |
|
9 |
|
|
10 |
Unless required by applicable law or agreed to in writing, software |
|
11 |
distributed under the License is distributed on an "AS IS" BASIS, |
|
12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 |
See the License for the specific language governing permissions and |
|
14 |
limitations under the License. |
|
15 |
|
|
16 |
Snowy采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: |
|
17 |
|
|
18 |
1.请不要删除和修改根目录下的LICENSE文件。 |
|
19 |
2.请不要删除和修改Snowy源码头部的版权声明。 |
|
20 |
3.请保留源码和相关描述文件的项目出处,作者声明等。 |
|
21 |
4.分发源码时候,请注明软件出处 https://gitee.com/xiaonuobase/snowy |
|
22 |
5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/xiaonuobase/snowy |
|
23 |
6.若您的项目无法满足以上几点,可申请商业授权,获取Snowy商业授权许可,请在官网购买授权,地址为 https://www.xiaonuo.vip |
|
24 |
*/ |
|
25 |
package vip.xiaonuo.modular.blogfriendshiplink.controller; |
|
26 |
|
|
27 |
import cn.hutool.core.bean.BeanUtil; |
|
28 |
import cn.hutool.core.lang.Dict; |
ff14c4
|
29 |
import org.springframework.validation.annotation.Validated; |
I |
30 |
import org.springframework.web.bind.annotation.*; |
4d51af
|
31 |
import vip.xiaonuo.core.annotion.BusinessLog; |
I |
32 |
import vip.xiaonuo.core.consts.CommonConstant; |
|
33 |
import vip.xiaonuo.core.consts.MyConstant; |
|
34 |
import vip.xiaonuo.core.enums.LogAnnotionOpTypeEnum; |
c49fa0
|
35 |
import vip.xiaonuo.core.exception.BlogException; |
4d51af
|
36 |
import vip.xiaonuo.core.pojo.response.ResponseData; |
I |
37 |
import vip.xiaonuo.core.pojo.response.SuccessResponseData; |
|
38 |
import vip.xiaonuo.modular.blogfriendshiplink.entity.BlogFriendshipLink; |
88f419
|
39 |
import vip.xiaonuo.modular.blogfriendshiplink.entity.BlogLinkVo; |
ff14c4
|
40 |
import vip.xiaonuo.modular.blogfriendshiplink.param.BlogFriendshipLinkParam; |
I |
41 |
import vip.xiaonuo.modular.blogfriendshiplink.param.BlogFriendshipLinkVo; |
4d51af
|
42 |
import vip.xiaonuo.modular.blogfriendshiplink.service.BlogFriendshipLinkService; |
I |
43 |
import vip.xiaonuo.sys.modular.dict.param.SysDictTypeParam; |
|
44 |
import vip.xiaonuo.sys.modular.dict.service.SysDictTypeService; |
|
45 |
|
|
46 |
import javax.annotation.Resource; |
|
47 |
import java.util.ArrayList; |
|
48 |
import java.util.LinkedHashMap; |
|
49 |
import java.util.List; |
|
50 |
import java.util.Map; |
|
51 |
import java.util.function.Function; |
|
52 |
import java.util.stream.Collectors; |
|
53 |
|
|
54 |
/** |
|
55 |
* 友情链接 控制器 |
|
56 |
* |
|
57 |
* @author inleft |
|
58 |
* @date 2022-02-15 15:17:15 |
|
59 |
*/ |
|
60 |
@RestController |
|
61 |
@RequestMapping("/outside") |
|
62 |
public class BlogLinkOutsideController { |
|
63 |
|
|
64 |
@Resource |
|
65 |
private BlogFriendshipLinkService blogFriendshipLinkService; |
|
66 |
|
|
67 |
|
|
68 |
@Resource |
|
69 |
private SysDictTypeService sysDictTypeService; |
|
70 |
|
ff14c4
|
71 |
|
4d51af
|
72 |
/** |
I |
73 |
* 查询blog友情链接 |
|
74 |
* |
|
75 |
* @author inleft |
|
76 |
* @date 2022-02-09 18:20:22 |
|
77 |
*/ |
|
78 |
@GetMapping("/blogLink/queryBlogLinkGroup") |
|
79 |
@BusinessLog(title = "外部blog系统_blog友情链接组_查询", opType = LogAnnotionOpTypeEnum.QUERY) |
|
80 |
public ResponseData queryBlogLinkGroup() { |
|
81 |
|
|
82 |
List<BlogFriendshipLink> linkList = blogFriendshipLinkService.lambdaQuery() |
ff14c4
|
83 |
.eq(BlogFriendshipLink::getIsEnable, MyConstant.Yes) |
4d51af
|
84 |
.orderByAsc(BlogFriendshipLink::getTopValue) |
I |
85 |
.orderByAsc(BlogFriendshipLink::getName) |
|
86 |
.list(); |
|
87 |
Map<String, List<BlogFriendshipLink>> groupLink = linkList.stream() |
|
88 |
.collect(Collectors.groupingBy(e -> e.getLinkType().toString(), LinkedHashMap::new, Collectors.mapping(Function.identity(), |
|
89 |
Collectors.toList()))); |
|
90 |
|
|
91 |
SysDictTypeParam param = new SysDictTypeParam(); |
|
92 |
param.setCode("blog_link_type"); |
|
93 |
List<Dict> dictList = sysDictTypeService.dropDown(param); |
|
94 |
|
|
95 |
List<BlogLinkVo> res = new ArrayList<>(dictList.size()); |
|
96 |
List<BlogFriendshipLink> tempLink; |
|
97 |
BlogLinkVo vo; |
|
98 |
|
|
99 |
for (Dict dict : dictList) { |
|
100 |
if ((tempLink = groupLink.get(dict.get(CommonConstant.CODE))) != null) { |
|
101 |
vo = new BlogLinkVo(); |
|
102 |
vo.setGroupName(dict.get(CommonConstant.VALUE).toString()); |
|
103 |
vo.setLinkVoList(tempLink.stream().map(e -> { |
|
104 |
BlogFriendshipLinkVo tempLinkVo = new BlogFriendshipLinkVo(); |
|
105 |
BeanUtil.copyProperties(e, tempLinkVo); |
|
106 |
return tempLinkVo; |
|
107 |
}).collect(Collectors.toList())); |
|
108 |
res.add(vo); |
|
109 |
} |
|
110 |
} |
|
111 |
|
|
112 |
return new SuccessResponseData(res); |
|
113 |
} |
ff14c4
|
114 |
|
I |
115 |
|
|
116 |
/** |
|
117 |
* 添加友情链接 |
|
118 |
* |
|
119 |
* @author inleft |
|
120 |
* @date 2022-02-17 15:05:44 |
|
121 |
*/ |
|
122 |
@PostMapping("/blogLink/add") |
|
123 |
@BusinessLog(title = "外部blog系统_blog友情链接_增加", opType = LogAnnotionOpTypeEnum.ADD) |
|
124 |
public ResponseData add(@RequestBody @Validated(BlogFriendshipLinkParam.add.class) BlogFriendshipLinkParam blogFriendshipLinkParam) { |
c49fa0
|
125 |
|
I |
126 |
if (blogFriendshipLinkService.lambdaQuery() |
|
127 |
.eq(BlogFriendshipLink::getUrl, blogFriendshipLinkParam.getUrl()) |
|
128 |
.count() > 0) { |
|
129 |
throw new BlogException("已经有该链接的记录啦,不要重复提交哦.."); |
|
130 |
} |
|
131 |
|
ff14c4
|
132 |
blogFriendshipLinkParam.setIsEnable(MyConstant.Yes); |
I |
133 |
blogFriendshipLinkService.add(blogFriendshipLinkParam); |
|
134 |
return new SuccessResponseData(); |
|
135 |
} |
|
136 |
|
|
137 |
|
|
138 |
@GetMapping("/blogLink/getLinkType") |
|
139 |
@BusinessLog(title = "外部blog系统_blog友情链接_获取链接类型", opType = LogAnnotionOpTypeEnum.QUERY) |
|
140 |
public ResponseData getLinkType() { |
|
141 |
|
|
142 |
|
|
143 |
SysDictTypeParam param = new SysDictTypeParam(); |
|
144 |
param.setCode("blog_link_type"); |
|
145 |
param.setStatus(MyConstant.No); |
|
146 |
List<Dict> dictList = sysDictTypeService.dropDown(param); |
|
147 |
|
|
148 |
List<BlogLinkVo> res = new ArrayList<>(dictList.size()); |
|
149 |
BlogLinkVo vo; |
|
150 |
|
|
151 |
for (Dict dict : dictList) { |
|
152 |
vo = new BlogLinkVo(); |
|
153 |
vo.setGroupName(dict.get(CommonConstant.VALUE).toString()); |
|
154 |
vo.setLinkTypeId(dict.getLong(CommonConstant.CODE)); |
|
155 |
res.add(vo); |
|
156 |
} |
|
157 |
return new SuccessResponseData(res); |
|
158 |
} |
|
159 |
|
4d51af
|
160 |
} |