Skip to content

Commit fc18b4e

Browse files
committed
新增组织架构CRUD
1 parent 043b7de commit fc18b4e

File tree

60 files changed

+3136
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+3136
-9
lines changed

hsweb-system/hsweb-system-authorization/hsweb-system-authorization-controller/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<dependency>
3939
<groupId>org.hswebframework</groupId>
4040
<artifactId>hsweb-expands-security</artifactId>
41-
<version>3.0.0-SNAPSHOT</version>
41+
<version>${hsweb.expands.version}</version>
4242
</dependency>
4343
<dependency>
4444
<groupId>org.hswebframework.web</groupId>

hsweb-system/hsweb-system-authorization/hsweb-system-authorization-dao/hsweb-system-authorization-dao-api/src/main/java/org/hswebframework/web/dao/authorization/PermissionDao.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.hswebframework.web.dao.authorization;
22

33
import org.hswebframework.web.dao.CrudDao;
4-
import org.hswebframework.web.entity.authorization.ActionEntity;
54
import org.hswebframework.web.entity.authorization.PermissionEntity;
65

76
/**

hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/PermissionEntity.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*
2+
* Copyright 2016 http://www.hswebframework.org
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+
*
17+
*/
18+
119
package org.hswebframework.web.entity.authorization;
220

321
import org.hswebframework.web.commons.entity.GenericEntity;

hsweb-system/hsweb-system-authorization/hsweb-system-authorization-entity/src/main/java/org/hswebframework/web/entity/authorization/SimplePermissionEntity.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import org.hibernate.validator.constraints.NotBlank;
44
import org.hswebframework.web.commons.entity.SimpleGenericEntity;
55

6-
import java.util.ArrayList;
76
import java.util.List;
87
import java.util.stream.Collectors;
98

hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<dependency>
1616
<groupId>org.hswebframework</groupId>
1717
<artifactId>hsweb-expands-security</artifactId>
18-
<version>3.0.0-SNAPSHOT</version>
18+
<version>${hsweb.expands.version}</version>
1919
</dependency>
2020
<dependency>
2121
<groupId>org.hswebframework.web</groupId>

hsweb-system/hsweb-system-authorization/hsweb-system-authorization-service/hsweb-system-authorization-service-simple/src/main/java/org/hswebframework/web/service/authorization/simple/SimplePermissionService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.hswebframework.web.dao.authorization.PermissionDao;
44
import org.hswebframework.web.entity.authorization.PermissionEntity;
5+
import org.hswebframework.web.id.IDGenerator;
56
import org.hswebframework.web.service.GenericEntityService;
67
import org.hswebframework.web.service.authorization.PermissionService;
78
import org.springframework.beans.factory.annotation.Autowired;
@@ -18,6 +19,11 @@ public class SimplePermissionService extends GenericEntityService<PermissionEnti
1819
@Autowired
1920
private PermissionDao permissionDao;
2021

22+
@Override
23+
protected IDGenerator<String> getIDGenerator() {
24+
return IDGenerator.MD5;
25+
}
26+
2127
@Override
2228
public PermissionDao getDao() {
2329
return permissionDao;

hsweb-system/hsweb-system-authorization/hsweb-system-authorization-starter/src/test/java/org/hswebframework/web/starter/authorization/PermissionTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ public void testCRUD() throws Exception {
7474
Assert.assertEquals(data.getName(), entity.getName());
7575
Assert.assertEquals(data.getStatus(), entity.getStatus());
7676
Assert.assertNotNull(data.getDataAccess());
77-
Assert.assertEquals(data.getDataAccess().get(0).getAction(),dataAccessEntity.getAction());
78-
Assert.assertEquals(data.getDataAccess().get(0).getType(),dataAccessEntity.getType());
77+
Assert.assertEquals(data.getDataAccess().get(0).getAction(), dataAccessEntity.getAction());
78+
Assert.assertEquals(data.getDataAccess().get(0).getType(), dataAccessEntity.getType());
7979

8080
data.setName("测试修改");
81-
permissionService.updateByPk(data);
81+
permissionService.updateByPk(data.getId(), data);
8282
PermissionEntity data2 = permissionService.selectByPk("test");
8383
Assert.assertEquals(data2.getName(), data.getName());
8484

hsweb-system/hsweb-system-config/hsweb-system-config-controller/src/main/java/org/hswebframework/web/controller/config/ConfigController.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@
2121
import org.hswebframework.web.authorization.annotation.Authorize;
2222
import org.hswebframework.web.commons.entity.param.QueryParamEntity;
2323
import org.hswebframework.web.controller.GenericEntityController;
24+
import org.hswebframework.web.controller.message.ResponseMessage;
2425
import org.hswebframework.web.entity.config.ConfigEntity;
2526
import org.hswebframework.web.logging.AccessLogger;
2627
import org.hswebframework.web.service.config.ConfigService;
2728
import org.springframework.beans.factory.annotation.Autowired;
29+
import org.springframework.web.bind.annotation.PathVariable;
30+
import org.springframework.web.bind.annotation.RequestBody;
2831
import org.springframework.web.bind.annotation.RequestMapping;
2932
import org.springframework.web.bind.annotation.RestController;
3033

@@ -50,4 +53,9 @@ public void setConfigService(ConfigService configService) {
5053
public ConfigService getService() {
5154
return configService;
5255
}
56+
57+
@Override
58+
public ResponseMessage updateByPrimaryKey(@PathVariable String id, @RequestBody ConfigEntity data) {
59+
return GenericEntityController.super.updateByPrimaryKey(id, data);
60+
}
5361
}

hsweb-system/hsweb-system-config/hsweb-system-config-service/hsweb-system-config-service-simple/src/main/java/org/hswebframework/web/service/config/simple/SimpleConfigService.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.hswebframework.web.dao.config.ConfigDao;
2222
import org.hswebframework.web.entity.config.ConfigEntity;
23+
import org.hswebframework.web.id.IDGenerator;
2324
import org.hswebframework.web.service.GenericEntityService;
2425
import org.hswebframework.web.service.config.ConfigService;
2526
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,6 +38,11 @@ public class SimpleConfigService extends GenericEntityService<ConfigEntity, Stri
3738
@Autowired
3839
private ConfigDao configDao;
3940

41+
@Override
42+
protected IDGenerator<String> getIDGenerator() {
43+
return IDGenerator.MD5;
44+
}
45+
4046
@Override
4147
public ConfigDao getDao() {
4248
return configDao;

hsweb-system/hsweb-system-config/hsweb-system-config-starter/src/test/java/org/hswebframework/web/starter/config/ConfigTests.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ public void testMvc() throws Exception {
7070
.getObject(0, SimpleConfigEntity.class)
7171
.get("test")
7272
.getNumber(0).intValue(), 1);
73+
74+
jsonObject = testPut("/config/" + configBean.getId())
75+
.setUp(builder -> builder.accept(MediaType.APPLICATION_JSON)
76+
.contentType(MediaType.APPLICATION_JSON)
77+
.content(jsonStr)
78+
)
79+
.exec().resultAsJson();
80+
Assert.assertEquals(200, jsonObject.get("status"));
7381
}
7482

7583
@Test
@@ -90,7 +98,7 @@ public void test() throws SQLException {
9098
configBean = configService.selectSingle(QueryParamEntity.empty());
9199
configBean.addContent("test2", "2", "");
92100
//test update
93-
Assert.assertEquals(configService.updateByPk(configBean), 1);
101+
Assert.assertEquals(configService.updateByPk(configBean.getId(), configBean), 1);
94102
Assert.assertEquals(configBean.get("test2").getNumber(0).intValue(), 2);
95103
configBean = configService.selectSingle(QueryParamEntity.empty());
96104
//test delete

hsweb-system/hsweb-system-explorer/hsweb-system-explorer-starter/src/test/java/org/hswebframework/web/starter/explorer/MenuTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public MenuEntity<MenuEntity> createMenu(String name, String... actions) {
5757
@Test
5858
public void testCrud() throws Exception {
5959
MenuEntity<MenuEntity> menuEntity = createMenu("测试1", "C", "R");
60-
menuEntity.setSortIndex(1);
60+
menuEntity.setSortIndex(1L);
6161
MenuEntity<MenuEntity> child1 = createMenu("测试2", "C", "R");
6262
MenuEntity<MenuEntity> child3 = createMenu("测试2", "C", "R");
6363
menuEntity.setChildren(Arrays.asList(child1, child3));
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2016 http://www.hswebframework.org
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
-->
18+
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
<parent>
23+
<artifactId>hsweb-system-organizational</artifactId>
24+
<groupId>org.hswebframework.web</groupId>
25+
<version>3.0-SNAPSHOT</version>
26+
</parent>
27+
<modelVersion>4.0.0</modelVersion>
28+
29+
<artifactId>hsweb-system-organizational-controller</artifactId>
30+
31+
<dependencies>
32+
<dependency>
33+
<groupId>javax.servlet</groupId>
34+
<artifactId>servlet-api</artifactId>
35+
<version>2.5</version>
36+
<optional>true</optional>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.hswebframework.web</groupId>
40+
<artifactId>hsweb-system-organizational-service-api</artifactId>
41+
<version>${project.version}</version>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.hswebframework.web</groupId>
45+
<artifactId>hsweb-commons-controller</artifactId>
46+
<version>${project.version}</version>
47+
</dependency>
48+
</dependencies>
49+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2016 http://www.hswebframework.org
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+
*/
17+
18+
package org.hswebframework.web.controller.organizational;
19+
20+
import org.hswebframework.web.authorization.annotation.Authorize;
21+
import org.hswebframework.web.commons.entity.param.QueryParamEntity;
22+
import org.hswebframework.web.controller.GenericEntityController;
23+
import org.hswebframework.web.entity.organizational.DepartmentEntity;
24+
import org.hswebframework.web.logging.AccessLogger;
25+
import org.hswebframework.web.service.organizational.DepartmentService;
26+
import org.springframework.beans.factory.annotation.Autowired;
27+
import org.springframework.web.bind.annotation.RequestMapping;
28+
import org.springframework.web.bind.annotation.RestController;
29+
30+
/**
31+
* 部门
32+
*
33+
* @author hsweb-generator-online
34+
*/
35+
@RestController
36+
@RequestMapping("${hsweb.web.mappings.department:department}")
37+
@Authorize(permission = "department")
38+
@AccessLogger("部门管理")
39+
public class DepartmentController implements GenericEntityController<DepartmentEntity, String, QueryParamEntity> {
40+
41+
private DepartmentService departmentService;
42+
43+
@Autowired
44+
public void setDepartmentService(DepartmentService departmentService) {
45+
this.departmentService = departmentService;
46+
}
47+
48+
@Override
49+
public DepartmentService getService() {
50+
return departmentService;
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2016 http://www.hswebframework.org
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+
*/
17+
18+
package org.hswebframework.web.controller.organizational;
19+
20+
import org.hswebframework.web.authorization.annotation.Authorize;
21+
import org.hswebframework.web.commons.entity.param.QueryParamEntity;
22+
import org.hswebframework.web.controller.GenericEntityController;
23+
import org.hswebframework.web.entity.organizational.OrganizationalEntity;
24+
import org.hswebframework.web.logging.AccessLogger;
25+
import org.hswebframework.web.service.organizational.OrganizationalService;
26+
import org.springframework.beans.factory.annotation.Autowired;
27+
import org.springframework.web.bind.annotation.RequestMapping;
28+
import org.springframework.web.bind.annotation.RestController;
29+
30+
/**
31+
* 组织
32+
*
33+
* @author hsweb-generator-online
34+
*/
35+
@RestController
36+
@RequestMapping("${hsweb.web.mappings.organizational:organizational}")
37+
@Authorize(permission = "organizational")
38+
@AccessLogger("组织管理")
39+
public class OrganizationalController implements GenericEntityController<OrganizationalEntity, String, QueryParamEntity> {
40+
41+
private OrganizationalService organizationalService;
42+
43+
@Autowired
44+
public void setOrganizationalService(OrganizationalService organizationalService) {
45+
this.organizationalService = organizationalService;
46+
}
47+
48+
@Override
49+
public OrganizationalService getService() {
50+
return organizationalService;
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2016 http://www.hswebframework.org
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+
*/
17+
18+
package org.hswebframework.web.controller.organizational;
19+
20+
import org.hswebframework.web.authorization.annotation.Authorize;
21+
import org.hswebframework.web.commons.entity.param.QueryParamEntity;
22+
import org.hswebframework.web.controller.GenericEntityController;
23+
import org.hswebframework.web.entity.organizational.PersonEntity;
24+
import org.hswebframework.web.logging.AccessLogger;
25+
import org.hswebframework.web.service.organizational.PersonService;
26+
import org.springframework.beans.factory.annotation.Autowired;
27+
import org.springframework.web.bind.annotation.RequestMapping;
28+
import org.springframework.web.bind.annotation.RestController;
29+
30+
/**
31+
* 人员
32+
*
33+
* @author hsweb-generator-online
34+
*/
35+
@RestController
36+
@RequestMapping("${hsweb.web.mappings.person:person}")
37+
@Authorize(permission = "person")
38+
@AccessLogger("人员")
39+
public class PersonController implements GenericEntityController<PersonEntity, String, QueryParamEntity> {
40+
41+
private PersonService personService;
42+
43+
@Autowired
44+
public void setPersonService(PersonService personService) {
45+
this.personService = personService;
46+
}
47+
48+
@Override
49+
public PersonService getService() {
50+
return personService;
51+
}
52+
}

0 commit comments

Comments
 (0)