权限/空间管理调整
parent
228a2fdd27
commit
640262e9e5
|
@ -11,4 +11,6 @@ public interface SpaceRepository extends MongoRepository<Space, String> {
|
||||||
|
|
||||||
List<Space> findByUidOrderByCreateAtDesc(String uid);
|
List<Space> findByUidOrderByCreateAtDesc(String uid);
|
||||||
|
|
||||||
|
List<Space> findByUidAndHomeIdOrderByCreateAtDesc(String uid, String homeId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,12 @@ public class KeycloakSecurityConfig extends KeycloakWebSecurityConfigurerAdapter
|
||||||
.antMatchers("/*.html", "/favicon.ico", "/v2/api-docs", "/webjars/**", "/swagger-resources/**", "/*.js").permitAll()
|
.antMatchers("/*.html", "/favicon.ico", "/v2/api-docs", "/webjars/**", "/swagger-resources/**", "/*.js").permitAll()
|
||||||
.antMatchers("/api/**").hasRole("iot_client_user")
|
.antMatchers("/api/**").hasRole("iot_client_user")
|
||||||
.antMatchers("/aligenieDevice/invoke/**").hasRole("iot_client_user")
|
.antMatchers("/aligenieDevice/invoke/**").hasRole("iot_client_user")
|
||||||
|
//客户端用户写权限
|
||||||
|
.antMatchers("/space/addSpace/**").hasRole("iot_client_user")
|
||||||
|
.antMatchers("/space/saveSpace/**").hasRole("iot_client_user")
|
||||||
|
.antMatchers("/space/delSpace/**").hasRole("iot_client_user")
|
||||||
|
.antMatchers("/space/saveHome/**").hasRole("iot_client_user")
|
||||||
|
|
||||||
.antMatchers(HttpMethod.DELETE).hasRole("iot_write")
|
.antMatchers(HttpMethod.DELETE).hasRole("iot_write")
|
||||||
.antMatchers(HttpMethod.PUT).hasRole("iot_write")
|
.antMatchers(HttpMethod.PUT).hasRole("iot_write")
|
||||||
.antMatchers("/**/save*/**").hasRole("iot_write")
|
.antMatchers("/**/save*/**").hasRole("iot_write")
|
||||||
|
|
|
@ -26,6 +26,17 @@ public class SpaceController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataOwnerService dataOwnerService;
|
private DataOwnerService dataOwnerService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取用户当前家庭
|
||||||
|
*/
|
||||||
|
@GetMapping("/currentHome")
|
||||||
|
public Home getCurrentHome() {
|
||||||
|
return homeRepository.findByUidAndCurrent(AuthUtil.getUserId(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存家庭信息
|
||||||
|
*/
|
||||||
@PostMapping("/saveHome/{id}")
|
@PostMapping("/saveHome/{id}")
|
||||||
public void saveHome(@PathVariable("id") String id, Home home) {
|
public void saveHome(@PathVariable("id") String id, Home home) {
|
||||||
Optional<Home> optHome = homeRepository.findById(id);
|
Optional<Home> optHome = homeRepository.findById(id);
|
||||||
|
@ -44,17 +55,17 @@ public class SpaceController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 我的空间设备列表
|
* 我的空间列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/spaces")
|
@GetMapping("/spaces/{homeId}")
|
||||||
public List<Space> getSpaces() {
|
public List<Space> getSpaces(@PathVariable("homeId") String homeId) {
|
||||||
return spaceRepository.findByUidOrderByCreateAtDesc(AuthUtil.getUserId());
|
return spaceRepository.findByUidAndHomeIdOrderByCreateAtDesc(AuthUtil.getUserId(), homeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在当前家庭中添加空间
|
* 在当前家庭中添加空间
|
||||||
*/
|
*/
|
||||||
@PostMapping("/add")
|
@PostMapping("/addSpace")
|
||||||
public void addSpace(String name) {
|
public void addSpace(String name) {
|
||||||
String uid = AuthUtil.getUserId();
|
String uid = AuthUtil.getUserId();
|
||||||
Home currHome = homeRepository.findByUidAndCurrent(uid, true);
|
Home currHome = homeRepository.findByUidAndCurrent(uid, true);
|
||||||
|
|
Loading…
Reference in New Issue