Skip to content

Commit 3a0c53d

Browse files
committed
添加对查询回收站的权限拦截
设置swagger只能再开发环境下可以查询 更新回收站删除后文件和图片没有一起删除的问题
1 parent 08bbad4 commit 3a0c53d

File tree

18 files changed

+246
-195
lines changed

18 files changed

+246
-195
lines changed

springboot-dubbo-api/src/main/java/com/lzq/api/service/ExampleService.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import com.github.pagehelper.PageInfo;
55
import com.lzq.api.pojo.Example;
66

7+
import java.util.List;
8+
79
/**
810
* (Example)表服务接口
911
*
@@ -53,9 +55,10 @@ public interface ExampleService {
5355
*
5456
* @param username 用户名
5557
* @param currentPage 当前页
58+
* @param orderCondition
5659
* @return
5760
*/
58-
PageInfo<Example> queryByPublic(String username, Integer currentPage);
61+
PageInfo<Example> queryByPublic(String username, Integer currentPage,Integer orderCondition);
5962

6063
/**
6164
* 删除实例(物理删除实例)
@@ -80,4 +83,26 @@ public interface ExampleService {
8083
*/
8184
Example queryByIdUsername(Example example);
8285

86+
87+
/**
88+
* 查询用户的回收站
89+
* @param username
90+
* @return
91+
*/
92+
List<Example> queryRecycle(String username);
93+
94+
/**
95+
* 恢复回收站实例
96+
* @param exampleId
97+
* @return
98+
*/
99+
Boolean resumeExample(String exampleId);
100+
101+
/**
102+
* 查询回收站是否有该实例
103+
* @param example
104+
* @return
105+
*/
106+
Example getExampleByDeleted(Example example);
107+
83108
}

springboot-dubbo-service/src/main/java/com/lzq/dubboservice/mapper/ExampleMapper.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package com.lzq.dubboservice.mapper;
22

3-
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
43
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5-
import com.lzq.api.dto.ExampleAccount;
6-
import com.lzq.api.pojo.Account;
74
import com.lzq.api.pojo.Example;
85
import org.apache.ibatis.annotations.Param;
6+
import org.springframework.security.core.parameters.P;
97
import org.springframework.stereotype.Repository;
108

119
import java.util.List;
@@ -19,4 +17,10 @@
1917
public interface ExampleMapper extends BaseMapper<Example> {
2018

2119
Integer deleteExample(@Param("exampleId")String exampleId);
20+
21+
List<Example> queryDeleted(@Param("username") String username);
22+
23+
Integer resumeExample(@Param("exmapleId") String exampleId);
24+
25+
Example getExampleByDeleted(Example example);
2226
}

springboot-dubbo-service/src/main/java/com/lzq/dubboservice/service/ExampleServiceImpl.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,21 @@ public PageInfo<Example> queryByAccount(String username, Integer currentPage, In
5858
}
5959

6060
@Override
61-
public PageInfo<Example> queryByPublic(String username, Integer currentPage) {
61+
public PageInfo<Example> queryByPublic(String username, Integer currentPage, Integer orderCondition) {
6262
QueryWrapper<Example> wrapper = new QueryWrapper<>();
6363
wrapper.eq("username", username);
6464
wrapper.eq("ispublic", 0);
65+
switch (orderCondition){
66+
case 0:
67+
wrapper.orderByDesc("create_time");
68+
break;
69+
case 1:
70+
wrapper.orderByDesc("update_time");
71+
break;
72+
case 2:
73+
wrapper.orderByDesc("favorites");
74+
break;
75+
}
6576
//当前页和每页条数
6677
PageHelper.startPage(currentPage, 12);
6778
List<Example> list = baseMapper.selectList(wrapper);
@@ -89,5 +100,20 @@ public Example queryByIdUsername(Example example) {
89100
return baseMapper.selectOne(wrapper);
90101
}
91102

103+
@Override
104+
public List<Example> queryRecycle(String username) {
105+
return baseMapper.queryDeleted(username);
106+
}
107+
108+
@Override
109+
public Boolean resumeExample(String exampleId) {
110+
return baseMapper.resumeExample(exampleId)>0?true:false;
111+
}
112+
113+
@Override
114+
public Example getExampleByDeleted(Example example) {
115+
return baseMapper.getExampleByDeleted(example);
116+
}
117+
92118

93119
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
resources:
2-
route: /home/demo/data/
3-
InitHtml: /home/demo/data/HelloWord.html
2+
route: F:/项目/MyDemo/data/
3+
InitHtml: F:/项目/MyDemo/data/HelloWord.html
44

55
qiniuyun:
6-
accessKey: Z_7eMJdtj_n4lrAdSs3zVuZ8rn4wZXu75b1gYJbC
7-
secretKey: QIriVPlgNKoKdjU02q166-7IBPy3z9sQTMn5Ae7R
8-
bucket: js-encoder
6+
accessKey: fIf9nYz-wQo3HD1AlhQ5wrUrdjtygUPGe2dpuLlY
7+
secretKey: ItVUX8sAaxsuj7kgmk3IZ0ip3BHljAx61N8m922C
8+
bucket: lzqwxr
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resources:
2+
route: /home/demo/data/
3+
InitHtml: /home/demo/data/HelloWord.html
4+
5+
qiniuyun:
6+
accessKey: Z_7eMJdtj_n4lrAdSs3zVuZ8rn4wZXu75b1gYJbC
7+
secretKey: QIriVPlgNKoKdjU02q166-7IBPy3z9sQTMn5Ae7R
8+
bucket: js-encoder

springboot-dubbo-service/src/main/resources/application-test.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

springboot-dubbo-service/src/main/resources/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
spring:
22
profiles:
3-
active: test
3+
active: dev
44
application:
55
#项目名称
66
name: service
Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
33
<mapper namespace="com.lzq.dubboservice.mapper.ExampleMapper">
4-
54
<delete id="deleteExample">
6-
delete from example where example_id=#{exampleId} and deleted=1
5+
delete from example
6+
where
7+
example_id=#{exampleId} and deleted=1
78
</delete>
9+
<select id="queryDeleted" resultType="com.lzq.api.pojo.Example">
10+
select
11+
example_id, example_name, update_time
12+
from example
13+
where
14+
username=#{username} and deleted=1;
15+
</select>
16+
<update id="resumeExample">
17+
update example
18+
set
19+
deleted=0
20+
where
21+
example_id=#{exmapleId}
22+
</update>
23+
<select id="getExampleByDeleted" resultType="com.lzq.api.pojo.Example">
24+
select
25+
example_id, img, file_name, username
26+
from example
27+
where
28+
username=#{username} and example_id=#{exampleId} and deleted=1
29+
</select>
30+
831
</mapper>

springboot-dubbo-web/src/main/java/com/lzq/web/config/SecurityConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ protected void configure(HttpSecurity http) throws Exception {
8282
.authorizeRequests()
8383
//放行index接口
8484
.antMatchers("/").permitAll()
85-
.antMatchers("/user/**", "/example/**", "/index/verify", "/feedback/**").
85+
.antMatchers("/user/**", "/example/**", "/index/verify", "/feedback/**","/query/getRecycle").
8686

8787
authenticated()
8888
//所有请求都需要登录验证

springboot-dubbo-web/src/main/java/com/lzq/web/config/SwaggerConfig.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,23 @@ public class SwaggerConfig {
2222
@Bean
2323
public Docket docket(Environment environment){
2424

25+
//设置要显示的Swagger环境
26+
Profiles profiles = Profiles.of("prod");
27+
28+
//通过environment.acceptsProfiles判断是否处于当前的环境中
29+
boolean flag = environment.acceptsProfiles(profiles);
30+
31+
2532
return new Docket(DocumentationType.SWAGGER_2)
2633
//编写api的基本信息
2734
.apiInfo(apiInfo())
35+
//enable是否启动Swagger,如果为false,则Swagger不能在浏览器中访问
36+
.enable(flag)
2837
.select()
2938
.apis(RequestHandlerSelectors.basePackage("com.lzq.web.controller"))
3039
//paths():过滤路径
3140
//PathSelectors.ant():只扫描扫描下的接口
32-
// .paths(PathSelectors.ant("/lzq/**"))
33-
.build()
34-
;
41+
.build();
3542
}
3643

3744

0 commit comments

Comments
 (0)