Skip to content

Commit dbe7c9b

Browse files
committed
feat:add admin config and update control tool and classifier tool
1 parent b1ddafd commit dbe7c9b

32 files changed

+2344
-74
lines changed

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ mysql,redis,emqx和influxdb环境。
8888
欢迎加入群聊一起交流讨论有关Aiot相关的话题,免费获取智控台的前端源码,链接过期了可以issue或email提醒一下作者。
8989

9090
<div style="width: 250px;margin: 0 auto;">
91-
<img src="./images/92681d0249ae4164f95b35e7158ba3b5.jpg" width="250px"/>
91+
<img src="./images/fa321a463dcf716c43ec2f0f6d556ba8.jpg" width="250px"/>
9292
</div>
9393

9494

-166 KB
Binary file not shown.
167 KB
Loading

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ mysql,redis,emqx和influxdb环境,安装详情请看官方文档。
116116
欢迎加入群聊一起交流讨论有关Aiot相关的话题,有机会获取项目的免费部署咨询,链接过期了可以issue或email提醒一下作者。
117117

118118
<div style="width: 250px;margin: 0 auto;">
119-
<img src="./docs/images/92681d0249ae4164f95b35e7158ba3b5.jpg" width="250px"/>
119+
<img src="./docs/images/fa321a463dcf716c43ec2f0f6d556ba8.jpg" width="250px"/>
120120
</div>
121121

122122
## 致谢

src/main/java/top/rslly/iot/controllers/Auth.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public class Auth {
7171
private McpServerServiceImpl mcpServerService;
7272
@Autowired
7373
private ProductRouterSetServiceImpl productRouterSetService;
74+
@Autowired
75+
private AdminConfigServiceImpl adminConfigService;
7476

7577

7678
@Operation(summary = "创建新用户", description = "暂不支持创建管理员用户")
@@ -453,4 +455,32 @@ public JsonResult<?> deleteMcpServer(@RequestParam("id") int id,
453455
}
454456
return mcpServerService.deleteMcpServer(id);
455457
}
458+
459+
@PreAuthorize("hasRole('ROLE_admin')")
460+
@Operation(summary = "获取管理员配置列表", description = "仅获取管理员配置列表")
461+
@RequestMapping(value = "/adminConfig", method = RequestMethod.GET)
462+
public JsonResult<?> getAdminConfig() {
463+
return adminConfigService.getAdminConfig();
464+
}
465+
466+
@PreAuthorize("hasRole('ROLE_admin')")
467+
@Operation(summary = "添加管理员配置", description = "仅添加管理员配置")
468+
@RequestMapping(value = "/adminConfig", method = RequestMethod.POST)
469+
public JsonResult<?> postAdminConfig(@Valid @RequestBody AdminConfig adminConfig) {
470+
return adminConfigService.postAdminConfig(adminConfig);
471+
}
472+
473+
@PreAuthorize("hasRole('ROLE_admin')")
474+
@Operation(summary = "修改管理员配置", description = "仅修改管理员配置")
475+
@RequestMapping(value = "/adminConfig", method = RequestMethod.PUT)
476+
public JsonResult<?> putAdminConfig(@Valid @RequestBody AdminConfig adminConfig) {
477+
return adminConfigService.putAdminConfig(adminConfig);
478+
}
479+
480+
@PreAuthorize("hasRole('ROLE_admin')")
481+
@Operation(summary = "删除管理员配置", description = "仅删除管理员配置")
482+
@RequestMapping(value = "/adminConfig", method = RequestMethod.DELETE)
483+
public JsonResult<?> deleteAdminConfig(@RequestParam("id") int id) {
484+
return adminConfigService.deleteAdminConfig(id);
485+
}
456486
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Copyright © 2023-2030 The ruanrongman Authors
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package top.rslly.iot.dao;
21+
22+
import org.springframework.data.jpa.repository.JpaRepository;
23+
import org.springframework.data.jpa.repository.Modifying;
24+
import org.springframework.data.jpa.repository.Query;
25+
import org.springframework.data.repository.query.Param;
26+
import org.springframework.transaction.annotation.Transactional;
27+
import top.rslly.iot.models.AdminConfigEntity;
28+
29+
import java.util.List;
30+
31+
public interface AdminConfigRepository extends JpaRepository<AdminConfigEntity, Long> {
32+
33+
List<AdminConfigEntity> findAllById(int id);
34+
35+
List<AdminConfigEntity> findAllBySetKey(String setKey);
36+
37+
@Modifying
38+
@Transactional
39+
@Query("UPDATE AdminConfigEntity e SET e.setValue = :setValue WHERE e.setKey = :setKey")
40+
void updateConfig(@Param("setKey") String setKey, @Param("setValue") String setValue);
41+
42+
@Transactional
43+
List<AdminConfigEntity> deleteAllById(int id);
44+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/**
2+
* Copyright © 2023-2030 The ruanrongman Authors
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package top.rslly.iot.models;
21+
22+
import javax.persistence.*;
23+
import java.util.Objects;
24+
25+
@Entity
26+
@Table(name = "admin_config", schema = "cwliot1.8", catalog = "")
27+
public class AdminConfigEntity {
28+
private int id;
29+
private String setKey;
30+
private String setValue;
31+
32+
@Id
33+
@GeneratedValue(strategy = GenerationType.IDENTITY)
34+
@Column(name = "id")
35+
public int getId() {
36+
return id;
37+
}
38+
39+
public void setId(int id) {
40+
this.id = id;
41+
}
42+
43+
@Basic
44+
@Column(name = "set_key")
45+
public String getSetKey() {
46+
return setKey;
47+
}
48+
49+
public void setSetKey(String setKey) {
50+
this.setKey = setKey;
51+
}
52+
53+
@Basic
54+
@Column(name = "set_value")
55+
public String getSetValue() {
56+
return setValue;
57+
}
58+
59+
public void setSetValue(String setValue) {
60+
this.setValue = setValue;
61+
}
62+
63+
@Override
64+
public boolean equals(Object o) {
65+
if (this == o)
66+
return true;
67+
if (o == null || getClass() != o.getClass())
68+
return false;
69+
AdminConfigEntity that = (AdminConfigEntity) o;
70+
return id == that.id && Objects.equals(setKey, that.setKey)
71+
&& Objects.equals(setValue, that.setValue);
72+
}
73+
74+
@Override
75+
public int hashCode() {
76+
return Objects.hash(id, setKey, setValue);
77+
}
78+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright © 2023-2030 The ruanrongman Authors
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package top.rslly.iot.param.request;
21+
22+
import lombok.Data;
23+
24+
import javax.validation.constraints.NotBlank;
25+
import javax.validation.constraints.Size;
26+
27+
@Data
28+
public class AdminConfig {
29+
@NotBlank(message = "setKey 不能为空")
30+
@Size(min = 1, max = 255, message = "setKey 长度必须在 1 到 255 之间")
31+
private String setKey;
32+
@NotBlank(message = "setValue 不能为空")
33+
@Size(min = 1, max = 255, message = "setValue 长度必须在 1 到 255 之间")
34+
private String setValue;
35+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright © 2023-2030 The ruanrongman Authors
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package top.rslly.iot.services;
21+
22+
import top.rslly.iot.models.AdminConfigEntity;
23+
import top.rslly.iot.param.request.AdminConfig;
24+
import top.rslly.iot.utility.result.JsonResult;
25+
26+
import java.util.List;
27+
28+
public interface AdminConfigService {
29+
30+
List<AdminConfigEntity> findAllBySetKey(String setKey);
31+
32+
JsonResult<?> getAdminConfig();
33+
34+
JsonResult<?> postAdminConfig(AdminConfig adminConfig);
35+
36+
JsonResult<?> putAdminConfig(AdminConfig adminConfig);
37+
38+
JsonResult<?> deleteAdminConfig(int id);
39+
}

0 commit comments

Comments
 (0)