Commit b1c24772d0a6c7d0763acd239fa31165069d72bd
0 parents
初始化项目
Showing
58 changed files
with
4844 additions
and
0 deletions
Too many changes to show.
To preserve performance only 58 of 331 files are displayed.
.gitignore
0 → 100644
diligrp-manage-dao/.gitignore
0 → 100644
diligrp-manage-dao/pom.xml
0 → 100644
1 | +++ a/diligrp-manage-dao/pom.xml | ||
1 | +<?xml version="1.0"?> | ||
2 | +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
4 | + <modelVersion>4.0.0</modelVersion> | ||
5 | + <parent> | ||
6 | + <groupId>com.b2c.manage</groupId> | ||
7 | + <artifactId>diligrp-manage</artifactId> | ||
8 | + <version>0.0.1-SNAPSHOT</version> | ||
9 | + </parent> | ||
10 | + <groupId>com.b2c.manage.dao</groupId> | ||
11 | + <artifactId>diligrp-manage-dao</artifactId> | ||
12 | + <packaging>jar</packaging> | ||
13 | + <name>diligrp-manage-dao</name> | ||
14 | + <url>http://maven.apache.org</url> | ||
15 | + <properties> | ||
16 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
17 | + </properties> | ||
18 | + <dependencies> | ||
19 | + <dependency> | ||
20 | + <groupId>com.b2c.manage.domain</groupId> | ||
21 | + <artifactId>diligrp-manage-domain</artifactId> | ||
22 | + <version>0.0.1-SNAPSHOT</version> | ||
23 | + </dependency> | ||
24 | + </dependencies> | ||
25 | + <build> | ||
26 | + <finalName>diligrp-manage-dao</finalName> | ||
27 | + </build> | ||
28 | +</project> |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/DataAuthDao.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/DataAuthDao.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao; | ||
3 | + | ||
4 | +import com.diligrp.website.util.dao.IBaseDao; | ||
5 | + | ||
6 | +import com.diligrp.manage.domain.DataAuth; | ||
7 | + | ||
8 | +import java.util.List; | ||
9 | + | ||
10 | +/** | ||
11 | + * <B>Description</B> <br /> | ||
12 | + * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. | ||
13 | + * <br /> | ||
14 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
15 | + * <B>Company</B> 地利集团 | ||
16 | + * | ||
17 | + * @createTime 2015-10-4 10:02:13 | ||
18 | + * @author template | ||
19 | + */ | ||
20 | +public interface DataAuthDao extends IBaseDao<DataAuth> { | ||
21 | + public List<DataAuth> findByType(Long userId, String type); | ||
22 | + | ||
23 | + public List<DataAuth> findByUser(Long userId); | ||
24 | + | ||
25 | + public DataAuth findByData(Long userId, String type, String dataAuth); | ||
26 | + | ||
27 | + public List<DataAuth> findByParentDataId(String parentDataId, String type, Long userId); | ||
28 | +} |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/MenuDao.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/MenuDao.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao; | ||
3 | + | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | + | ||
7 | +import org.springframework.stereotype.Component; | ||
8 | + | ||
9 | +import com.diligrp.website.util.dao.IBaseDao; | ||
10 | +import com.diligrp.website.util.dao.BaseQuery; | ||
11 | + | ||
12 | +import com.diligrp.manage.domain.Menu; | ||
13 | +import com.diligrp.manage.domain.MenuJson; | ||
14 | + | ||
15 | +/** | ||
16 | + * <B>Description</B> <br /> | ||
17 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
18 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
19 | + * <B>Company</B> 地利集团 | ||
20 | + * @createTime 2014-7-3 14:24:39 | ||
21 | + * @author template | ||
22 | + */ | ||
23 | +public interface MenuDao extends IBaseDao<Menu> { | ||
24 | + /** | ||
25 | + * 根据用户ID获取菜单 | ||
26 | + * @param id | ||
27 | + * @return | ||
28 | + */ | ||
29 | + public List<Menu> findByUserId(Long id); | ||
30 | + | ||
31 | + | ||
32 | + /** | ||
33 | + * 根据父节点查询菜单 | ||
34 | + * @param id | ||
35 | + * @return | ||
36 | + */ | ||
37 | + public List<Menu> findByParent(Long id); | ||
38 | + | ||
39 | + /** | ||
40 | + * 查询出所有的菜单 | ||
41 | + * @return | ||
42 | + */ | ||
43 | + public List<Menu> findAll(); | ||
44 | + | ||
45 | + public List<Menu> findByRole(Long id); | ||
46 | + | ||
47 | + public Boolean delByNavbar(Long id); | ||
48 | + | ||
49 | + | ||
50 | + public List<MenuJson> findAllMenuJson(); | ||
51 | + | ||
52 | + | ||
53 | + public Integer countAllChild(Long parentId); | ||
54 | +} |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/NavbarDao.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/NavbarDao.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao; | ||
3 | + | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | + | ||
7 | +import org.springframework.stereotype.Component; | ||
8 | + | ||
9 | +import com.diligrp.website.util.dao.IBaseDao; | ||
10 | +import com.diligrp.website.util.dao.BaseQuery; | ||
11 | + | ||
12 | +import com.diligrp.manage.domain.Navbar; | ||
13 | + | ||
14 | +/** | ||
15 | + * <B>Description</B> <br /> | ||
16 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
17 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
18 | + * <B>Company</B> 地利集团 | ||
19 | + * @createTime 2014-7-3 14:24:40 | ||
20 | + * @author template | ||
21 | + */ | ||
22 | +public interface NavbarDao extends IBaseDao<Navbar> { | ||
23 | + public List<Navbar> findAll(BaseQuery bq); | ||
24 | + | ||
25 | + /** | ||
26 | + * 根据名称查询 | ||
27 | + * @param name | ||
28 | + * @return | ||
29 | + */ | ||
30 | + public Navbar findByCode(String name); | ||
31 | +} |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/ResourceDao.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/ResourceDao.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao; | ||
3 | + | ||
4 | + | ||
5 | +import com.diligrp.manage.domain.Resource; | ||
6 | +import com.diligrp.website.util.dao.IBaseDao; | ||
7 | + | ||
8 | +import java.util.List; | ||
9 | + | ||
10 | +/** | ||
11 | + * <B>Description</B> <br /> | ||
12 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
13 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
14 | + * <B>Company</B> 地利集团 | ||
15 | + * @createTime 2014-7-3 14:24:40 | ||
16 | + * @author template | ||
17 | + */ | ||
18 | +public interface ResourceDao extends IBaseDao<Resource> { | ||
19 | + | ||
20 | +// TODO:并不清楚最终目的,转 ResourceUrlDao | ||
21 | + List<Resource> listAllResourceJson(Resource req); | ||
22 | + | ||
23 | + /** | ||
24 | + * | ||
25 | + * this method is 查询所有的Resource的URL记录 | ||
26 | + * @return | ||
27 | + * @createTime 2014-8-19 下午2:46:01 | ||
28 | + * @author Nick | ||
29 | + */ | ||
30 | +// TODO: 转 ResourceUrlDao | ||
31 | + public List<String> listAllUrls(); | ||
32 | + | ||
33 | + List<Resource> findByRole(Long id); | ||
34 | + | ||
35 | +// TODO: 转 ResourceUrlDao | ||
36 | + List<Resource> findAll(Integer status); | ||
37 | + | ||
38 | +// TODO: 检查唯一性 ? 可能不需要 | ||
39 | + boolean checkResourceUrlUnique(String url, Long id); | ||
40 | + | ||
41 | +// TODO: 检查唯一性 ? 可能不需要 | ||
42 | + boolean checkResourceNameUnique(String resourceName, Long id); | ||
43 | + | ||
44 | + List<Resource> findByParent(Long id); | ||
45 | +} |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/ResourceUrlDao.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/ResourceUrlDao.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao; | ||
3 | + | ||
4 | + | ||
5 | +import com.diligrp.manage.domain.ResourceUrl; | ||
6 | +import com.diligrp.website.util.dao.IBaseDao; | ||
7 | + | ||
8 | +import java.util.List; | ||
9 | + | ||
10 | +/** | ||
11 | + * <B>Description</B> <br /> | ||
12 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
13 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
14 | + * <B>Company</B> 地利集团 | ||
15 | + * @createTime 2014-7-3 14:24:40 | ||
16 | + * @author template | ||
17 | + */ | ||
18 | +public interface ResourceUrlDao extends IBaseDao<ResourceUrl> { | ||
19 | + | ||
20 | +// TODO: 转 ResourceUrlDao | ||
21 | +// List<Resource> findAll(Integer status); | ||
22 | + public boolean deleteByParentId(Long id); | ||
23 | + | ||
24 | + public List<ResourceUrl> listAll(); | ||
25 | + | ||
26 | + public List<ResourceUrl> getResUrlsByRoleId(Long roleId) ; | ||
27 | + | ||
28 | + public List<ResourceUrl> listByResourceID(Long id); | ||
29 | +} |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/RoleDao.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/RoleDao.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao; | ||
3 | + | ||
4 | + | ||
5 | +import com.diligrp.manage.domain.Role; | ||
6 | +import com.diligrp.manage.domain.RoleUser; | ||
7 | +import com.diligrp.manage.domain.UserRole; | ||
8 | +import com.diligrp.website.util.dao.IBaseDao; | ||
9 | + | ||
10 | +import java.util.List; | ||
11 | +import java.util.Map; | ||
12 | + | ||
13 | +/** | ||
14 | + * <B>Description</B> <br /> | ||
15 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
16 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
17 | + * <B>Company</B> 地利集团 | ||
18 | + * @createTime 2014-7-3 14:24:41 | ||
19 | + * @author template | ||
20 | + */ | ||
21 | +public interface RoleDao extends IBaseDao<Role> { | ||
22 | + | ||
23 | + List<Role> getAllRoles(); | ||
24 | + public Boolean saveRoleMenu(Map<String, Object> role); | ||
25 | + | ||
26 | + /** | ||
27 | + * 删除角色所有的权限 | ||
28 | + * @param id | ||
29 | + * @return | ||
30 | + */ | ||
31 | + public Boolean delByRole(Long id); | ||
32 | + | ||
33 | + /** | ||
34 | + * 根据菜单获取到角色 | ||
35 | + * @param id | ||
36 | + * @return | ||
37 | + */ | ||
38 | + public List<Role> findByMenu(Long id); | ||
39 | + public List<UserRole> findUserIdByRoleId(Long id); | ||
40 | + Boolean roleResourceBatchDelete(Long roleId, List<Long> resourceIdsToBeDeleted); | ||
41 | + Boolean roleResourceBatchInsert(Long roleId, List<Long> resourceIdsToBeAdded); | ||
42 | + | ||
43 | + /** | ||
44 | + * 用户角色 | ||
45 | + * @param roleId | ||
46 | + * @return | ||
47 | + */ | ||
48 | + public List<RoleUser> findUsersByRoleId(Long roleId); | ||
49 | + | ||
50 | + public void delUser(Long roleId, Long userId); | ||
51 | + | ||
52 | + public List<Role> findByResource(Long id); | ||
53 | + | ||
54 | + public List<Role> findByUserId(Long id); | ||
55 | +} |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/UserDao.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/UserDao.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao; | ||
3 | + | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | +import java.util.Map; | ||
7 | + | ||
8 | +import com.diligrp.manage.domain.User; | ||
9 | +import com.diligrp.manage.domain.UserRole; | ||
10 | +import com.diligrp.website.util.dao.IBaseDao; | ||
11 | + | ||
12 | +/** | ||
13 | + * <B>Description</B> <br /> | ||
14 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
15 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
16 | + * <B>Company</B> 地利集团 | ||
17 | + * @createTime 2014-7-3 14:24:41 | ||
18 | + * @author template | ||
19 | + */ | ||
20 | +public interface UserDao extends IBaseDao<User> { | ||
21 | + | ||
22 | + public User getUserByUserName(String userName); | ||
23 | + | ||
24 | + public Boolean saveUserRoles(Map<String, Long> map); | ||
25 | + | ||
26 | + public Long saveUser(User user); | ||
27 | + | ||
28 | + public Boolean deleteUserRoleByUserId(Long pk); | ||
29 | + | ||
30 | + public List<UserRole> findRolesByUserId(Long pk); | ||
31 | + public List<User> findUserByRole(Long id); | ||
32 | + | ||
33 | + public boolean checkUserNumber(String serialNumber, String id); | ||
34 | + | ||
35 | + public User findUserByIdIgoreDel(Long pk); | ||
36 | + | ||
37 | + List<String> receptByUsername(String username); | ||
38 | +} |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/UserResourceDao.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/UserResourceDao.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao; | ||
3 | + | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | +import java.util.Map; | ||
7 | + | ||
8 | +import org.springframework.stereotype.Component; | ||
9 | + | ||
10 | +import com.diligrp.manage.domain.UserResource; | ||
11 | +import com.diligrp.website.util.dao.IBaseDao; | ||
12 | +import com.diligrp.website.util.dao.BaseQuery; | ||
13 | + | ||
14 | + | ||
15 | +/** | ||
16 | + * <B>Description</B> <br /> | ||
17 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
18 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
19 | + * <B>Company</B> 地利集团 | ||
20 | + * @createTime 2014-7-3 14:24:39 | ||
21 | + * @author template | ||
22 | + */ | ||
23 | +public interface UserResourceDao extends IBaseDao<UserResource> { | ||
24 | + /** | ||
25 | + * 根据用户名称获取用户资源 | ||
26 | + * @param id | ||
27 | + * @return | ||
28 | + */ | ||
29 | + public Map<String, String> findResourceByUserName(String userName); | ||
30 | +} |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/DataAuthDaoImpl.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/DataAuthDaoImpl.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao.impl; | ||
3 | + | ||
4 | +import org.springframework.stereotype.Component; | ||
5 | + | ||
6 | +import com.diligrp.website.util.dao.impl.BaseDaoImpl; | ||
7 | +import com.diligrp.manage.dao.DataAuthDao; | ||
8 | + | ||
9 | +import com.diligrp.manage.domain.DataAuth; | ||
10 | + | ||
11 | +import java.util.HashMap; | ||
12 | +import java.util.List; | ||
13 | +import java.util.Map; | ||
14 | + | ||
15 | +/** | ||
16 | + * <B>Description</B> <br /> | ||
17 | + * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. | ||
18 | + * <br /> | ||
19 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
20 | + * <B>Company</B> 地利集团 | ||
21 | + * | ||
22 | + * @createTime 2015-10-4 10:02:13 | ||
23 | + * @author template | ||
24 | + */ | ||
25 | +@Component | ||
26 | +public class DataAuthDaoImpl extends BaseDaoImpl<DataAuth> implements DataAuthDao { | ||
27 | + | ||
28 | + private final String CLASS_NAME = this.getClass().getCanonicalName(); | ||
29 | + | ||
30 | + @Override | ||
31 | + public List<DataAuth> findByType(Long userId, String type) { | ||
32 | + Map<String, Object> map = new HashMap<>(); | ||
33 | + map.put("userId", userId); | ||
34 | + map.put("type", type); | ||
35 | + return getSqlSessionTemplate().selectList(CLASS_NAME + ".findByType", map); | ||
36 | + } | ||
37 | + | ||
38 | + @Override | ||
39 | + public List<DataAuth> findByUser(Long userId) { | ||
40 | + return getSqlSessionTemplate().selectList(CLASS_NAME + ".findByUser", userId); | ||
41 | + } | ||
42 | + | ||
43 | + @Override | ||
44 | + public DataAuth findByData(Long userId, String type, String dataAuth) { | ||
45 | + Map<String, Object> map = new HashMap<>(); | ||
46 | + map.put("userId", userId); | ||
47 | + map.put("type", type); | ||
48 | + map.put("dataId", dataAuth); | ||
49 | + return getSqlSessionTemplate().selectOne(CLASS_NAME + ".findByData", map); | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public List<DataAuth> findByParentDataId(String parentDataId, String type, Long userId) { | ||
54 | + Map<String, Object> params = new HashMap<>(); | ||
55 | + params.put("parentDataId", parentDataId); | ||
56 | + params.put("type", type); | ||
57 | + params.put("userId", userId); | ||
58 | + return this.getSqlSessionTemplate().selectList(CLASS_NAME + ".findByParentDataId", params); | ||
59 | + } | ||
60 | +} |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/MenuDaoImpl.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/MenuDaoImpl.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao.impl; | ||
3 | + | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | + | ||
7 | +import org.springframework.stereotype.Component; | ||
8 | + | ||
9 | +import com.diligrp.website.util.dao.impl.BaseDaoImpl; | ||
10 | +import com.diligrp.manage.dao.MenuDao; | ||
11 | + | ||
12 | + | ||
13 | +import com.diligrp.manage.domain.Menu; | ||
14 | +import com.diligrp.manage.domain.MenuJson; | ||
15 | + | ||
16 | +/** | ||
17 | + * <B>Description</B> <br /> | ||
18 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
19 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
20 | + * <B>Company</B> 地利集团 | ||
21 | + * @createTime 2014-7-3 14:24:39 | ||
22 | + * @author template | ||
23 | + */ | ||
24 | +@Component | ||
25 | +public class MenuDaoImpl extends BaseDaoImpl<Menu> implements MenuDao{ | ||
26 | + /** | ||
27 | + * 根据用户ID获取菜单 | ||
28 | + * @param id | ||
29 | + * @return | ||
30 | + */ | ||
31 | + public List<Menu> findByUserId(Long id) { | ||
32 | + return getSqlSessionTemplate().selectList(getClass().getCanonicalName() + ".findByUser", id); | ||
33 | + } | ||
34 | + | ||
35 | + /** | ||
36 | + * 根据父节点查询菜单 | ||
37 | + * @param id | ||
38 | + * @return | ||
39 | + */ | ||
40 | + public List<Menu> findByParent(Long id) { | ||
41 | + return getSqlSessionTemplate().selectList(getClass().getCanonicalName() + ".getByParent", id); | ||
42 | + } | ||
43 | + | ||
44 | + public List<Menu> findAll() { | ||
45 | + return getSqlSessionTemplate().selectList(getClass().getCanonicalName() + ".getAll"); | ||
46 | + } | ||
47 | + | ||
48 | + @Override | ||
49 | + public List<Menu> findByRole(Long id) { | ||
50 | + return getSqlSessionTemplate().selectList(getClass().getCanonicalName() + ".getByRole", id); | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + public Boolean delByNavbar(Long id) { | ||
55 | + return getSqlSessionTemplate().update(getClass().getCanonicalName() + ".delByNavbar", id) > 0; | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public List<MenuJson> findAllMenuJson() { | ||
60 | + return getSqlSessionTemplate().selectList(getClass().getCanonicalName() + ".getAllMenuJson"); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public Integer countAllChild(Long parentId) { | ||
65 | + return getSqlSessionTemplate().selectOne(getClass().getCanonicalName() + ".countAllChild", parentId); | ||
66 | + } | ||
67 | + | ||
68 | +} |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/NavbarDaoImpl.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/NavbarDaoImpl.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao.impl; | ||
3 | + | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | + | ||
7 | +import com.diligrp.website.util.dao.BaseQuery; | ||
8 | +import org.springframework.stereotype.Component; | ||
9 | + | ||
10 | +import com.diligrp.website.util.dao.impl.BaseDaoImpl; | ||
11 | +import com.diligrp.manage.dao.NavbarDao; | ||
12 | + | ||
13 | + | ||
14 | +import com.diligrp.manage.domain.Navbar; | ||
15 | + | ||
16 | +/** | ||
17 | + * <B>Description</B> <br /> | ||
18 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
19 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
20 | + * <B>Company</B> 地利集团 | ||
21 | + * @createTime 2014-7-3 14:24:40 | ||
22 | + * @author template | ||
23 | + */ | ||
24 | +@Component | ||
25 | +public class NavbarDaoImpl extends BaseDaoImpl<Navbar> implements NavbarDao{ | ||
26 | + @Override | ||
27 | + public List<Navbar> findAll(BaseQuery bq) { | ||
28 | + return getSqlSessionTemplate().selectList(this.getClass().getCanonicalName() + ".findAll", bq); | ||
29 | + } | ||
30 | + | ||
31 | + public Navbar findByCode(String name) { | ||
32 | + List<Navbar> list = getSqlSessionTemplate().selectList(this.getClass().getCanonicalName() + ".findByCode", name); | ||
33 | + if (list == null || list.size()<= 0) { | ||
34 | + return null; | ||
35 | + } | ||
36 | + return list.get(0); | ||
37 | + } | ||
38 | +} |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/ResourceDaoImpl.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/ResourceDaoImpl.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao.impl; | ||
3 | + | ||
4 | + | ||
5 | +import com.diligrp.manage.dao.ResourceDao; | ||
6 | +import com.diligrp.manage.domain.Resource; | ||
7 | +import com.diligrp.website.util.dao.impl.BaseDaoImpl; | ||
8 | +import org.springframework.stereotype.Component; | ||
9 | + | ||
10 | +import java.util.HashMap; | ||
11 | +import java.util.List; | ||
12 | +import java.util.Map; | ||
13 | + | ||
14 | +/** | ||
15 | + * <B>Description</B> <br /> | ||
16 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
17 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
18 | + * <B>Company</B> 地利集团 | ||
19 | + * @createTime 2014-7-3 14:24:40 | ||
20 | + * @author template | ||
21 | + */ | ||
22 | +@Component | ||
23 | +public class ResourceDaoImpl extends BaseDaoImpl<Resource> implements ResourceDao{ | ||
24 | + | ||
25 | + @Override | ||
26 | + public List<String> listAllUrls(){ | ||
27 | + return getSqlSessionTemplate().selectList(super.getClass().getCanonicalName() + ".listAllUrls"); | ||
28 | + } | ||
29 | + | ||
30 | + @Override | ||
31 | + public List<Resource> listAllResourceJson(Resource resource) { | ||
32 | + return getSqlSessionTemplate().selectList(getClass().getCanonicalName() + ".getAllResourceJson", resource); | ||
33 | + } | ||
34 | + | ||
35 | + @Override | ||
36 | + public List<Resource> findByRole(Long id) { | ||
37 | + return getSqlSessionTemplate().selectList(this.getClass().getCanonicalName()+ ".findByRole", id); | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public List<Resource> findAll(Integer status) { | ||
42 | + Map<String, Object> map = new HashMap<>(); | ||
43 | + map.put("status", status); | ||
44 | + return getSqlSessionTemplate().selectList(this.getClass().getCanonicalName() + ".findAll", map); | ||
45 | + } | ||
46 | + | ||
47 | + @Override | ||
48 | + public boolean checkResourceUrlUnique(String url, Long id) { | ||
49 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
50 | + map.put("url", url); | ||
51 | + map.put("id", id); | ||
52 | + return getSqlSessionTemplate().selectOne(this.getClass().getCanonicalName()+ ".checkResourceUrlUnique", map); | ||
53 | + } | ||
54 | + | ||
55 | + @Override | ||
56 | + public boolean checkResourceNameUnique(String resourceName, Long id) { | ||
57 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
58 | + map.put("resourceName", resourceName); | ||
59 | + map.put("id", id); | ||
60 | + return getSqlSessionTemplate().selectOne(this.getClass().getCanonicalName()+ ".checkResourceNameUnique", map); | ||
61 | + } | ||
62 | + | ||
63 | + | ||
64 | + @Override | ||
65 | + public List<Resource> findByParent(Long id) { | ||
66 | + return getSqlSessionTemplate().selectList(this.getClass().getCanonicalName()+ ".findByParent", id); | ||
67 | + } | ||
68 | + | ||
69 | +} |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/ResourceUrlDaoImpl.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/ResourceUrlDaoImpl.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao.impl; | ||
3 | + | ||
4 | + | ||
5 | +import com.diligrp.manage.dao.ResourceUrlDao; | ||
6 | +import com.diligrp.manage.domain.ResourceUrl; | ||
7 | +import com.diligrp.website.util.dao.impl.BaseDaoImpl; | ||
8 | +import org.springframework.stereotype.Component; | ||
9 | + | ||
10 | +import java.util.List; | ||
11 | + | ||
12 | +/** | ||
13 | + * <B>Description</B> <br /> | ||
14 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
15 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
16 | + * <B>Company</B> 地利集团 | ||
17 | + * @createTime 2014-7-3 14:24:40 | ||
18 | + * @author template | ||
19 | + */ | ||
20 | +@Component | ||
21 | +public class ResourceUrlDaoImpl extends BaseDaoImpl<ResourceUrl> implements ResourceUrlDao { | ||
22 | + @Override | ||
23 | + public boolean deleteByParentId(Long id) { | ||
24 | + return getSqlSessionTemplate().delete(this.getClass().getCanonicalName() + ".deleteByParentId", id) > 0; | ||
25 | + } | ||
26 | + | ||
27 | + public List<ResourceUrl> listAll(){ | ||
28 | + return getSqlSessionTemplate().selectList(this.getClass().getCanonicalName() + ".listAll"); | ||
29 | + } | ||
30 | + | ||
31 | + @Override | ||
32 | + public List<ResourceUrl> getResUrlsByRoleId(Long roleId) { | ||
33 | + return getSqlSessionTemplate().selectList(this.getClass().getCanonicalName() + ".getResUrlsByRoleId", roleId); | ||
34 | + } | ||
35 | + | ||
36 | + @Override | ||
37 | + public List<ResourceUrl> listByResourceID(Long id) { | ||
38 | + return getSqlSessionTemplate().selectList(this.getClass().getCanonicalName() + ".listByResourceID", id); | ||
39 | + } | ||
40 | + | ||
41 | +// @Override | ||
42 | +// public List<Resource> findAll(Integer status) { | ||
43 | +// Map<String, Object> map = new HashMap<>(); | ||
44 | +// map.put("status", status); | ||
45 | +// return getSqlSessionTemplate().selectList(this.getClass().getCanonicalName() + ".findAll", map); | ||
46 | +// } | ||
47 | + | ||
48 | + | ||
49 | +} |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/RoleDaoImpl.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/RoleDaoImpl.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao.impl; | ||
3 | + | ||
4 | + | ||
5 | +import com.diligrp.manage.dao.RoleDao; | ||
6 | +import com.diligrp.manage.domain.Role; | ||
7 | +import com.diligrp.manage.domain.RoleUser; | ||
8 | +import com.diligrp.manage.domain.UserRole; | ||
9 | +import com.diligrp.website.util.dao.impl.BaseDaoImpl; | ||
10 | +import org.springframework.stereotype.Component; | ||
11 | + | ||
12 | +import java.util.HashMap; | ||
13 | +import java.util.List; | ||
14 | +import java.util.Map; | ||
15 | + | ||
16 | +/** | ||
17 | + * <B>Description</B> <br /> | ||
18 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
19 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
20 | + * <B>Company</B> 地利集团 | ||
21 | + * @createTime 2014-7-3 14:24:41 | ||
22 | + * @author template | ||
23 | + */ | ||
24 | +@Component | ||
25 | +public class RoleDaoImpl extends BaseDaoImpl<Role> implements RoleDao{ | ||
26 | + | ||
27 | + @Override | ||
28 | + public List<Role> getAllRoles() { | ||
29 | + return getSqlSessionTemplate().selectList(this.getClass().getCanonicalName() + ".getAllRoles"); | ||
30 | + } | ||
31 | + | ||
32 | + @Override | ||
33 | + public Boolean saveRoleMenu(Map<String, Object> role) { | ||
34 | + return getSqlSessionTemplate().insert(getClass().getCanonicalName() + ".saveRoleMenu", role) > 0; | ||
35 | + } | ||
36 | + @Override | ||
37 | + public Boolean delByRole(Long id) { | ||
38 | + return getSqlSessionTemplate().delete(getClass().getCanonicalName() + ".delByRole", id) > 0; | ||
39 | + } | ||
40 | + @Override | ||
41 | + public List<Role> findByMenu(Long id) { | ||
42 | + return getSqlSessionTemplate().selectList(getClass().getCanonicalName() + ".getByMenu", id); | ||
43 | + } | ||
44 | + | ||
45 | + @Override | ||
46 | + public List<UserRole> findUserIdByRoleId(Long id) { | ||
47 | + return getSqlSessionTemplate().selectList(getClass().getCanonicalName() + ".findUserByRoleId", id); | ||
48 | + } | ||
49 | + | ||
50 | + @Override | ||
51 | + public Boolean roleResourceBatchDelete(Long roleId, List<Long> resourceIdsToBeDeleted) { | ||
52 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
53 | + map.put("roleId", roleId); | ||
54 | + map.put("resourceIds", resourceIdsToBeDeleted); | ||
55 | + return getSqlSessionTemplate().delete(getClass().getCanonicalName() + ".roleResourceBatchDelete", map) > 0; | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public Boolean roleResourceBatchInsert(Long roleId, List<Long> resourceIdsToBeAdded) { | ||
60 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
61 | + map.put("roleId", roleId); | ||
62 | + map.put("resourceIds", resourceIdsToBeAdded); | ||
63 | + return getSqlSessionTemplate().insert(getClass().getCanonicalName() + ".roleResourceBatchInsert", map) > 0; | ||
64 | + } | ||
65 | + | ||
66 | + @Override | ||
67 | + public List<RoleUser> findUsersByRoleId(Long roleId) { | ||
68 | + return getSqlSessionTemplate().selectList(super.getClass().getCanonicalName() + ".findUsersByRoleId", roleId); | ||
69 | + } | ||
70 | + | ||
71 | + @Override | ||
72 | + public void delUser(Long roleId, Long userId) { | ||
73 | + Map<String, Object> map = new HashMap<String, Object>(); | ||
74 | + map.put("roleId", roleId); | ||
75 | + map.put("userId", userId); | ||
76 | + getSqlSessionTemplate().delete(getClass().getCanonicalName() + ".delUser", map); | ||
77 | + } | ||
78 | + | ||
79 | + @Override | ||
80 | + public List<Role> findByResource(Long id) { | ||
81 | + return getSqlSessionTemplate().selectList(getClass().getCanonicalName() + ".findByResource", id); | ||
82 | + } | ||
83 | + | ||
84 | + @Override | ||
85 | + public List<Role> findByUserId(Long id) { | ||
86 | + return getSqlSessionTemplate().selectList(getClass().getCanonicalName() + ".findByUserId", id); | ||
87 | + } | ||
88 | +} |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/UserDaoImpl.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/UserDaoImpl.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao.impl; | ||
3 | + | ||
4 | + | ||
5 | +import java.util.ArrayList; | ||
6 | +import java.util.List; | ||
7 | +import java.util.Map; | ||
8 | + | ||
9 | +import org.springframework.stereotype.Component; | ||
10 | + | ||
11 | +import com.diligrp.manage.dao.UserDao; | ||
12 | +import com.diligrp.manage.domain.User; | ||
13 | +import com.diligrp.manage.domain.UserRole; | ||
14 | +import com.diligrp.website.util.dao.BaseQuery; | ||
15 | +import com.diligrp.website.util.dao.impl.BaseDaoImpl; | ||
16 | + | ||
17 | +/** | ||
18 | + * <B>Description</B> <br /> | ||
19 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
20 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
21 | + * <B>Company</B> 地利集团 | ||
22 | + * @createTime 2014-7-3 14:24:41 | ||
23 | + * @author template | ||
24 | + */ | ||
25 | +@Component | ||
26 | +public class UserDaoImpl extends BaseDaoImpl<User> implements UserDao{ | ||
27 | + | ||
28 | + @Override | ||
29 | + public User getUserByUserName(String userName){ | ||
30 | + return getSqlSessionTemplate().selectOne(super.getClass().getCanonicalName() + ".getByUserName", userName); | ||
31 | + } | ||
32 | + | ||
33 | + @Override | ||
34 | + public User findUserByIdIgoreDel(Long pk) { | ||
35 | + return getSqlSessionTemplate().selectOne(super.getClass().getCanonicalName() + ".getByUserByIdIgoreDel", pk); | ||
36 | + } | ||
37 | + | ||
38 | + @Override | ||
39 | + public List<String> receptByUsername(String username) { | ||
40 | + List<User> users = getSqlSessionTemplate().selectList(super.getClass().getCanonicalName() + ".receptByUsername", username); | ||
41 | + List<String> uns = new ArrayList<>(); | ||
42 | + for (User u : users) { | ||
43 | + uns.add(u.getUserName()); | ||
44 | + } | ||
45 | + return uns; | ||
46 | + } | ||
47 | + | ||
48 | + @Override | ||
49 | + public Boolean saveUserRoles(Map<String, Long> user) { | ||
50 | + return getSqlSessionTemplate().insert(super.getClass().getCanonicalName() + ".batchSaveUserRoles", user) > 0; | ||
51 | + } | ||
52 | + | ||
53 | + @Override | ||
54 | + public Long saveUser(User user) { | ||
55 | + getSqlSessionTemplate().insert(this.getClass().getCanonicalName() + ".save", user); | ||
56 | + return user.getId(); | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public List<UserRole> findRolesByUserId(Long pk) { | ||
61 | + return getSqlSessionTemplate().selectList(super.getClass().getCanonicalName() + ".findRolesByUserId", pk); | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public List<User> findUserByRole(Long id) { | ||
66 | + return getSqlSessionTemplate().selectList(super.getClass().getCanonicalName() + ".findUserByRole", id); | ||
67 | + } | ||
68 | + | ||
69 | + @Override | ||
70 | + public Boolean deleteUserRoleByUserId(Long pk) { | ||
71 | + return getSqlSessionTemplate().delete(this.getClass().getCanonicalName() + ".deleteUserRoleByUserId", pk) > 0; | ||
72 | + } | ||
73 | + | ||
74 | + @Override | ||
75 | + public boolean checkUserNumber(String serialNumber, String id) { | ||
76 | + if (id != null) { | ||
77 | + User user = this.getById(Long.parseLong(id)); | ||
78 | + if (serialNumber.equals(user.getSerialNumber())) { | ||
79 | + return true; | ||
80 | + } | ||
81 | + } | ||
82 | + List<User> userList = getSqlSessionTemplate().selectList(super.getClass().getCanonicalName() + ".checkUserNumber", serialNumber); | ||
83 | + return userList.size() > 0 ? false : true; | ||
84 | + | ||
85 | + } | ||
86 | + | ||
87 | +} | ||
88 | + |
diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/UserResourceDaoImpl.java
0 → 100644
1 | +++ a/diligrp-manage-dao/src/main/java/com/diligrp/manage/dao/impl/UserResourceDaoImpl.java | ||
1 | + | ||
2 | +package com.diligrp.manage.dao.impl; | ||
3 | + | ||
4 | + | ||
5 | +import java.util.HashMap; | ||
6 | +import java.util.List; | ||
7 | +import java.util.Map; | ||
8 | + | ||
9 | +import com.diligrp.manage.domain.Resource; | ||
10 | +import org.springframework.stereotype.Component; | ||
11 | + | ||
12 | +import com.diligrp.website.util.dao.impl.BaseDaoImpl; | ||
13 | +import com.diligrp.manage.dao.UserResourceDao; | ||
14 | + | ||
15 | + | ||
16 | +import com.diligrp.manage.domain.UserResource; | ||
17 | + | ||
18 | +/** | ||
19 | + * <B>Description</B> <br /> | ||
20 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
21 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
22 | + * <B>Company</B> 地利集团 | ||
23 | + * @createTime 2014-7-3 14:24:39 | ||
24 | + * @author template | ||
25 | + */ | ||
26 | +@Component | ||
27 | +public class UserResourceDaoImpl extends BaseDaoImpl<UserResource> implements UserResourceDao{ | ||
28 | + | ||
29 | + @Override | ||
30 | + public Map<String, String> findResourceByUserName(String userName) { | ||
31 | + Map<String, String> userResourceMap = new HashMap<String, String>(); | ||
32 | + List<UserResource> resourceList = getSqlSessionTemplate().selectList(getClass().getCanonicalName() + ".findResourceByUserName", userName); | ||
33 | + if (resourceList.size() > 0) { | ||
34 | + for (int i = 0; i < resourceList.size(); i++) { | ||
35 | + UserResource item = resourceList.get(i); | ||
36 | + if (item.getType().equals(3)) { | ||
37 | + userResourceMap.put("fragment:" + item.getUrl(), item.getResourceName()); | ||
38 | + } else { | ||
39 | + userResourceMap.put(item.getMethod() + "/" + item.getUrl(), item.getResourceName()); | ||
40 | + } | ||
41 | + } | ||
42 | + return userResourceMap; | ||
43 | + } | ||
44 | + return null; | ||
45 | + } | ||
46 | + | ||
47 | +} |
diligrp-manage-domain/.gitignore
0 → 100644
diligrp-manage-domain/pom.xml
0 → 100644
1 | +++ a/diligrp-manage-domain/pom.xml | ||
1 | +<?xml version="1.0"?> | ||
2 | +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
4 | + <modelVersion>4.0.0</modelVersion> | ||
5 | + <parent> | ||
6 | + <groupId>com.b2c.manage</groupId> | ||
7 | + <artifactId>diligrp-manage</artifactId> | ||
8 | + <version>0.0.1-SNAPSHOT</version> | ||
9 | + </parent> | ||
10 | + <groupId>com.b2c.manage.domain</groupId> | ||
11 | + <artifactId>diligrp-manage-domain</artifactId> | ||
12 | + <version>0.0.1-SNAPSHOT</version> | ||
13 | + <packaging>jar</packaging> | ||
14 | + <name>diligrp-manage-domain</name> | ||
15 | + <url>http://maven.apache.org</url> | ||
16 | + <properties> | ||
17 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
18 | + </properties> | ||
19 | + <dependencies> | ||
20 | + </dependencies> | ||
21 | + <build> | ||
22 | + <finalName>diligrp-manage-domain</finalName> | ||
23 | + </build> | ||
24 | +</project> |
diligrp-manage-domain/src/main/java/com/diligrp/manage/common/ManageUtils.java
0 → 100644
1 | +++ a/diligrp-manage-domain/src/main/java/com/diligrp/manage/common/ManageUtils.java | ||
1 | +package com.diligrp.manage.common; | ||
2 | + | ||
3 | +import javax.servlet.http.HttpServletRequest; | ||
4 | + | ||
5 | + | ||
6 | +public class ManageUtils { | ||
7 | + | ||
8 | + public static String getRemoteIP(HttpServletRequest request) { | ||
9 | + String ip = null; | ||
10 | + if ((request.getHeader("x-forwarded-for") != null) && (!"unknown".equalsIgnoreCase(request.getHeader("x-forwarded-for")))) { | ||
11 | + ip = request.getHeader("x-forwarded-for"); | ||
12 | + }else{ | ||
13 | + ip = request.getRemoteAddr(); | ||
14 | + } | ||
15 | + return ip; | ||
16 | + } | ||
17 | + | ||
18 | + | ||
19 | + | ||
20 | +} |
diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/DataAuth.java
0 → 100644
1 | +++ a/diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/DataAuth.java | ||
1 | +package com.diligrp.manage.domain; | ||
2 | + | ||
3 | +import com.diligrp.website.util.domain.BaseDomain; | ||
4 | + | ||
5 | +/** | ||
6 | + * <B>Description</B> <br /> | ||
7 | + * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. | ||
8 | + * <br /> | ||
9 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
10 | + * <B>Company</B> 地利集团 | ||
11 | + * | ||
12 | + * @createTime 2015-10-4 10:02:14 | ||
13 | + * @author template | ||
14 | + */ | ||
15 | +public class DataAuth extends BaseDomain { | ||
16 | + | ||
17 | + /** | ||
18 | + * | ||
19 | + */ | ||
20 | + private static final long serialVersionUID = -1664669029495999754L; | ||
21 | + /** | ||
22 | + * | ||
23 | + */ | ||
24 | + private String type; | ||
25 | + /** | ||
26 | + * 用户ID | ||
27 | + */ | ||
28 | + private Long userId; | ||
29 | + /** | ||
30 | + * 数据权限ID | ||
31 | + */ | ||
32 | + private String dataId; | ||
33 | + | ||
34 | + private String label; | ||
35 | + /** | ||
36 | + * 父级id | ||
37 | + */ | ||
38 | + private Long parentDataId; | ||
39 | + | ||
40 | + public void setType(String type) { | ||
41 | + this.type = type; | ||
42 | + } | ||
43 | + | ||
44 | + public String getType() { | ||
45 | + return this.type; | ||
46 | + } | ||
47 | + | ||
48 | + public void setUserId(Long userId) { | ||
49 | + this.userId = userId; | ||
50 | + } | ||
51 | + | ||
52 | + public Long getUserId() { | ||
53 | + return this.userId; | ||
54 | + } | ||
55 | + | ||
56 | + public String getDataId() { | ||
57 | + return dataId; | ||
58 | + } | ||
59 | + | ||
60 | + public void setDataId(String dataId) { | ||
61 | + this.dataId = dataId; | ||
62 | + } | ||
63 | + | ||
64 | + public String getLabel() { | ||
65 | + return label; | ||
66 | + } | ||
67 | + | ||
68 | + public void setLabel(String label) { | ||
69 | + this.label = label; | ||
70 | + } | ||
71 | + | ||
72 | + public Long getParentDataId() { | ||
73 | + return parentDataId; | ||
74 | + } | ||
75 | + | ||
76 | + public void setParentDataId(Long parentDataId) { | ||
77 | + this.parentDataId = parentDataId; | ||
78 | + } | ||
79 | + | ||
80 | + public String toString() { | ||
81 | + StringBuffer sb = new StringBuffer(); | ||
82 | + sb.append("dataAuth ["); | ||
83 | + sb.append("id = "); | ||
84 | + sb.append(id); | ||
85 | + sb.append(", type = "); | ||
86 | + sb.append(type); | ||
87 | + sb.append(", userId = "); | ||
88 | + sb.append(userId); | ||
89 | + sb.append(", dataId = "); | ||
90 | + sb.append(dataId); | ||
91 | + sb.append(", parentDataId = "); | ||
92 | + sb.append(this.parentDataId); | ||
93 | + sb.append("]"); | ||
94 | + return sb.toString(); | ||
95 | + } | ||
96 | +} | ||
0 | \ No newline at end of file | 97 | \ No newline at end of file |
diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/Menu.java
0 → 100644
1 | +++ a/diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/Menu.java | ||
1 | +package com.diligrp.manage.domain; | ||
2 | + | ||
3 | +import com.diligrp.website.util.domain.BaseDomain; | ||
4 | +import java.util.*; | ||
5 | + | ||
6 | + | ||
7 | +/** | ||
8 | + * <B>Description</B> <br /> | ||
9 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
10 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
11 | + * <B>Company</B> 地利集团 | ||
12 | + * @createTime 2014-7-3 14:24:39 | ||
13 | + * @author template | ||
14 | + */ | ||
15 | +public class Menu extends BaseDomain { | ||
16 | + | ||
17 | + /** | ||
18 | + * | ||
19 | + */ | ||
20 | + private static final long serialVersionUID = 1L; | ||
21 | + | ||
22 | + /** | ||
23 | + * 缓存菜单KEY | ||
24 | + */ | ||
25 | + private static final String REDIS_MENU_TREE_KEY = "dili_redis_MANAGE_MENU_"; | ||
26 | + | ||
27 | + /** | ||
28 | + * 类型目录 | ||
29 | + */ | ||
30 | + public static final Integer TYPE_DIR = 0; | ||
31 | + /** | ||
32 | + * 类型, 叶子 | ||
33 | + */ | ||
34 | + public static final Integer TYPE_LEAF = 1; | ||
35 | + | ||
36 | + | ||
37 | + /** | ||
38 | + * 父级id | ||
39 | + */ | ||
40 | + private Long parentId; | ||
41 | + | ||
42 | + /** | ||
43 | + * 子菜单 | ||
44 | + */ | ||
45 | + private List<Menu> children = new ArrayList<Menu>(); | ||
46 | + /** | ||
47 | + * 菜单排序 | ||
48 | + */ | ||
49 | + private Integer sort; | ||
50 | + /** | ||
51 | + * 是否为根节点 | ||
52 | + */ | ||
53 | + private Integer isRoot; | ||
54 | + /** | ||
55 | + * 菜单url | ||
56 | + */ | ||
57 | + private String menuUrl; | ||
58 | + /** | ||
59 | + * 菜单名字 | ||
60 | + */ | ||
61 | + private String label; | ||
62 | + /** | ||
63 | + * 菜单描述 | ||
64 | + */ | ||
65 | + private String description; | ||
66 | + /** | ||
67 | + * 打开链接的位置,0表示当前窗口,1表示新开窗口 | ||
68 | + */ | ||
69 | + private Integer target; | ||
70 | + /** | ||
71 | + * 外键 | ||
72 | + */ | ||
73 | + private Long navbarId; | ||
74 | + /** | ||
75 | + * 类型, 0目录, 1连接 | ||
76 | + */ | ||
77 | + private Integer type; | ||
78 | + | ||
79 | + /** | ||
80 | + * 第三方系统 | ||
81 | + */ | ||
82 | + private Navbar navbar; | ||
83 | + | ||
84 | + private Long resourceId; | ||
85 | + | ||
86 | + public Menu() { | ||
87 | + | ||
88 | + } | ||
89 | + | ||
90 | + public Menu(Long parentId) { | ||
91 | + this.parentId = parentId; | ||
92 | + } | ||
93 | + | ||
94 | + | ||
95 | + public void sortChildren() { | ||
96 | + List<Menu> child = this.getChildren(); | ||
97 | + if (child == null) { | ||
98 | + return; | ||
99 | + } | ||
100 | + Collections.sort(children, new Comparator<Menu>() { | ||
101 | + @Override | ||
102 | + public int compare(Menu a, Menu b) { | ||
103 | + if (a.getSort() < 0) { | ||
104 | + return -1; | ||
105 | + } | ||
106 | + if (b.getSort() < 0) { | ||
107 | + return 1; | ||
108 | + } | ||
109 | + if (a.getSort().equals(b.getSort())) { | ||
110 | + return 0; | ||
111 | + } | ||
112 | + if (a.getSort() < b.getSort()) { | ||
113 | + return -1; | ||
114 | + } | ||
115 | + return 1; | ||
116 | + } | ||
117 | + }); | ||
118 | + | ||
119 | + for (Menu menu : child) { | ||
120 | + menu.sortChildren(); | ||
121 | + } | ||
122 | + } | ||
123 | +// public void sortChildren() { | ||
124 | +// if (this.children == null) { | ||
125 | +// return; | ||
126 | +// } | ||
127 | +// for (Menu menu : children) { | ||
128 | +// menu.sortChildren(); | ||
129 | +// } | ||
130 | +// Collections.sort(children, new Comparator<Menu>() { | ||
131 | +// @Override | ||
132 | +// public int compare(Menu a, Menu b) { | ||
133 | +// return a.getSort() == b.getSort() ? 0 : a.getSort() < b.getSort() ? -1 : 1; | ||
134 | +// } | ||
135 | +// }); | ||
136 | +// } | ||
137 | + | ||
138 | + /** | ||
139 | + * 根据父节点设置是否是根结点 | ||
140 | + */ | ||
141 | + public void initRoot(){ | ||
142 | + if (this.getParentId() == null || this.getParentId() <= 0) { | ||
143 | + this.setIsRoot(1); | ||
144 | + } else { | ||
145 | + this.setIsRoot(0); | ||
146 | + } | ||
147 | + } | ||
148 | + | ||
149 | + public void setParentId (Long parentId){ | ||
150 | + this.parentId = parentId; | ||
151 | + } | ||
152 | + public Long getParentId(){ | ||
153 | + return this.parentId; | ||
154 | + } | ||
155 | + | ||
156 | + public void setSort (Integer sort){ | ||
157 | + this.sort = sort; | ||
158 | + } | ||
159 | + public Integer getSort(){ | ||
160 | + return this.sort; | ||
161 | + } | ||
162 | + | ||
163 | + public void setIsRoot (Integer isRoot){ | ||
164 | + this.isRoot = isRoot; | ||
165 | + } | ||
166 | + public Integer getIsRoot(){ | ||
167 | + return this.isRoot; | ||
168 | + } | ||
169 | + | ||
170 | + public void setMenuUrl (String menuUrl){ | ||
171 | + this.menuUrl = menuUrl; | ||
172 | + } | ||
173 | + public String getMenuUrl(){ | ||
174 | + return this.menuUrl; | ||
175 | + } | ||
176 | + | ||
177 | + public String getLabel() { | ||
178 | + return label; | ||
179 | + } | ||
180 | + | ||
181 | + public void setLabel(String label) { | ||
182 | + this.label = label; | ||
183 | + } | ||
184 | + | ||
185 | + public void setDescription (String description){ | ||
186 | + this.description = description; | ||
187 | + } | ||
188 | + public String getDescription(){ | ||
189 | + return this.description; | ||
190 | + } | ||
191 | + | ||
192 | + public void setTarget (Integer target){ | ||
193 | + this.target = target; | ||
194 | + } | ||
195 | + public Integer getTarget(){ | ||
196 | + return this.target; | ||
197 | + } | ||
198 | + | ||
199 | + public void setNavbarId (Long navbarId){ | ||
200 | + this.navbarId = navbarId; | ||
201 | + } | ||
202 | + public Long getNavbarId(){ | ||
203 | + return this.navbarId; | ||
204 | + } | ||
205 | + | ||
206 | + public void setType (Integer type){ | ||
207 | + this.type = type; | ||
208 | + } | ||
209 | + public Integer getType(){ | ||
210 | + return this.type; | ||
211 | + } | ||
212 | + | ||
213 | + public Navbar getNavbar() { | ||
214 | + return navbar; | ||
215 | + } | ||
216 | + | ||
217 | + public Long getResourceId() { | ||
218 | + return resourceId; | ||
219 | + } | ||
220 | + | ||
221 | + public void setResourceId(Long resourceId) { | ||
222 | + this.resourceId = resourceId; | ||
223 | + } | ||
224 | + | ||
225 | + public void setNavbar(Navbar navbar) { | ||
226 | + this.navbar = navbar; | ||
227 | + } | ||
228 | + | ||
229 | + public List<Menu> getChildren() { | ||
230 | + return children; | ||
231 | + } | ||
232 | + | ||
233 | + public void setChildren(List<Menu> children) { | ||
234 | + this.children = children; | ||
235 | + } | ||
236 | + | ||
237 | + public void addChildren(Menu menu) { | ||
238 | + if (children == null) { | ||
239 | + children = new ArrayList<>(); | ||
240 | + } | ||
241 | + children.add(menu); | ||
242 | + } | ||
243 | + | ||
244 | + public String toString(){ | ||
245 | + StringBuffer sb = new StringBuffer(); | ||
246 | + sb.append("Menu ["); | ||
247 | + sb.append("id = "); | ||
248 | + sb.append(id); | ||
249 | + sb.append(", parentId = "); | ||
250 | + sb.append(parentId); | ||
251 | + sb.append(", sort = "); | ||
252 | + sb.append(sort); | ||
253 | + sb.append(", isRoot = "); | ||
254 | + sb.append(isRoot); | ||
255 | + sb.append(", menuUrl = "); | ||
256 | + sb.append(menuUrl); | ||
257 | + sb.append(", label = "); | ||
258 | + sb.append(label); | ||
259 | + sb.append(", description = "); | ||
260 | + sb.append(description); | ||
261 | + sb.append(", target = "); | ||
262 | + sb.append(target); | ||
263 | + sb.append(", navbarId = "); | ||
264 | + sb.append(navbarId); | ||
265 | + sb.append(", created = "); | ||
266 | + sb.append(created); | ||
267 | + sb.append(", modified = "); | ||
268 | + sb.append(modified); | ||
269 | + sb.append(", navbar = "); | ||
270 | + sb.append(navbar); | ||
271 | + sb.append(", type = "); | ||
272 | + sb.append(type); | ||
273 | + sb.append(", childSize = "); | ||
274 | + sb.append(children.size()); | ||
275 | + sb.append("]"); | ||
276 | + return sb.toString(); | ||
277 | + } | ||
278 | + | ||
279 | + /** | ||
280 | + * 子列表REDIS KEY | ||
281 | + * @param id | ||
282 | + * @return | ||
283 | + */ | ||
284 | + public static String listChildrenKey(Long id) { | ||
285 | + return REDIS_MENU_TREE_KEY + "_CHILDREN_" + id; | ||
286 | + } | ||
287 | + | ||
288 | + /** | ||
289 | + * 单个menu的REDIS | ||
290 | + * @param id | ||
291 | + * @return | ||
292 | + */ | ||
293 | + public static String itemKey(Long id) { | ||
294 | + return REDIS_MENU_TREE_KEY + "_ITEM_" + id; | ||
295 | + } | ||
296 | + | ||
297 | + public static String allTreeKey() { | ||
298 | + return REDIS_MENU_TREE_KEY + "_ALL_TREE"; | ||
299 | + } | ||
300 | +} | ||
0 | \ No newline at end of file | 301 | \ No newline at end of file |
diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/MenuJson.java
0 → 100644
1 | +++ a/diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/MenuJson.java | ||
1 | +package com.diligrp.manage.domain; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.annotation.JSONField; | ||
4 | +import com.diligrp.website.util.domain.BaseDomain; | ||
5 | +import java.util.*; | ||
6 | + | ||
7 | + | ||
8 | +/** | ||
9 | + * <B>Description</B> <br /> | ||
10 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
11 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
12 | + * <B>Company</B> 地利集团 | ||
13 | + * @createTime 2014-7-3 14:24:39 | ||
14 | + * @author template | ||
15 | + */ | ||
16 | +public class MenuJson extends BaseDomain { | ||
17 | + | ||
18 | + private static final long serialVersionUID = 1L; | ||
19 | + | ||
20 | + private Long parentId; | ||
21 | + | ||
22 | + private Integer sort; | ||
23 | + | ||
24 | + private String menuUrl; | ||
25 | + | ||
26 | + private String label; | ||
27 | + | ||
28 | + private String description; | ||
29 | + | ||
30 | + private Long resourceId; | ||
31 | + | ||
32 | + @JSONField(name="_parentId") | ||
33 | + public Long getParentId() { | ||
34 | + return parentId; | ||
35 | + } | ||
36 | + public void setParentId(Long parentId) { | ||
37 | + this.parentId = parentId; | ||
38 | + } | ||
39 | + | ||
40 | + public Integer getSort() { | ||
41 | + return sort; | ||
42 | + } | ||
43 | + | ||
44 | + public void setSort(Integer sort) { | ||
45 | + this.sort = sort; | ||
46 | + } | ||
47 | + | ||
48 | + public String getMenuUrl() { | ||
49 | + return menuUrl; | ||
50 | + } | ||
51 | + | ||
52 | + public void setMenuUrl(String menuUrl) { | ||
53 | + this.menuUrl = menuUrl; | ||
54 | + } | ||
55 | + | ||
56 | + public String getLabel() { | ||
57 | + return label; | ||
58 | + } | ||
59 | + | ||
60 | + public void setLabel(String label) { | ||
61 | + this.label = label; | ||
62 | + } | ||
63 | + | ||
64 | + public String getDescription() { | ||
65 | + return description; | ||
66 | + } | ||
67 | + | ||
68 | + public void setDescription(String description) { | ||
69 | + this.description = description; | ||
70 | + } | ||
71 | + | ||
72 | + | ||
73 | + public Long getResourceId() { | ||
74 | + return resourceId; | ||
75 | + } | ||
76 | + public void setResourceId(Long resourceId) { | ||
77 | + this.resourceId = resourceId; | ||
78 | + } | ||
79 | + @Override | ||
80 | + public String toString() { | ||
81 | + return "MenuJson [parentId=" + parentId + ", sort=" + sort | ||
82 | + + ", menuUrl=" + menuUrl + ", label=" + label | ||
83 | + + ", description=" + description + ", id=" + id + ", created=" | ||
84 | + + created + ", modified=" + modified + ", yn=" + yn + "]"; | ||
85 | + } | ||
86 | + | ||
87 | +} | ||
0 | \ No newline at end of file | 88 | \ No newline at end of file |
diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/Navbar.java
0 → 100644
1 | +++ a/diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/Navbar.java | ||
1 | +package com.diligrp.manage.domain; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | +import com.diligrp.website.util.domain.BaseDomain; | ||
5 | +import java.util.*; | ||
6 | +import java.sql.Timestamp; | ||
7 | + | ||
8 | + | ||
9 | +/** | ||
10 | + * <B>Description</B> <br /> | ||
11 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
12 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
13 | + * <B>Company</B> 地利集团 | ||
14 | + * @createTime 2014-7-3 14:24:40 | ||
15 | + * @author template | ||
16 | + */ | ||
17 | +public class Navbar extends BaseDomain { | ||
18 | + | ||
19 | + /** | ||
20 | + * 项目名字 | ||
21 | + */ | ||
22 | + private String projectName; | ||
23 | + /** | ||
24 | + * 项目描述 | ||
25 | + */ | ||
26 | + private String description; | ||
27 | + | ||
28 | + /** | ||
29 | + * 系统统一编号 | ||
30 | + */ | ||
31 | + private String code; | ||
32 | + | ||
33 | + public void setProjectName (String projectName){ | ||
34 | + this.projectName = projectName; | ||
35 | + } | ||
36 | + public String getProjectName(){ | ||
37 | + return this.projectName; | ||
38 | + } | ||
39 | + | ||
40 | + public void setDescription (String description){ | ||
41 | + this.description = description; | ||
42 | + } | ||
43 | + public String getDescription(){ | ||
44 | + return this.description; | ||
45 | + } | ||
46 | + | ||
47 | + public String getCode() { | ||
48 | + return code; | ||
49 | + } | ||
50 | + | ||
51 | + public void setCode(String code) { | ||
52 | + this.code = code; | ||
53 | + } | ||
54 | + | ||
55 | + public String toString(){ | ||
56 | + StringBuffer sb = new StringBuffer(); | ||
57 | + sb.append("Navbar ["); | ||
58 | + sb.append("id = "); | ||
59 | + sb.append(id); | ||
60 | + sb.append(", projectName = "); | ||
61 | + sb.append(projectName); | ||
62 | + sb.append(", description = "); | ||
63 | + sb.append(description); | ||
64 | + sb.append(", created = "); | ||
65 | + sb.append(created); | ||
66 | + sb.append(", modified = "); | ||
67 | + sb.append(modified); | ||
68 | + sb.append("]"); | ||
69 | + return sb.toString(); | ||
70 | + } | ||
71 | +} | ||
0 | \ No newline at end of file | 72 | \ No newline at end of file |
diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/Resource.java
0 → 100644
1 | +++ a/diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/Resource.java | ||
1 | +package com.diligrp.manage.domain; | ||
2 | + | ||
3 | +import org.apache.commons.lang3.StringUtils; | ||
4 | + | ||
5 | +import com.diligrp.website.util.domain.BaseDomain; | ||
6 | + | ||
7 | + | ||
8 | +/** | ||
9 | + * <B>Description</B> <br /> | ||
10 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
11 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
12 | + * <B>Company</B> 地利集团 | ||
13 | + * @createTime 2014-7-3 14:24:40 | ||
14 | + * @author template | ||
15 | + */ | ||
16 | +public class Resource extends BaseDomain { | ||
17 | + | ||
18 | + public static final Integer TYPE_URL = 1; | ||
19 | + public static final Integer TYPE_API = 2; | ||
20 | + public static final Integer TYPE_FRAGEMENT = 3; | ||
21 | + | ||
22 | + /** | ||
23 | + * 资源名称 | ||
24 | + */ | ||
25 | + private String resourceName; | ||
26 | + /** | ||
27 | + * 资源描述 | ||
28 | + */ | ||
29 | + private String description; | ||
30 | + /** | ||
31 | + * 外键 | ||
32 | + */ | ||
33 | + private Long navbarId; | ||
34 | + | ||
35 | + /** | ||
36 | + * 父ID | ||
37 | + */ | ||
38 | + private Long parentId; | ||
39 | + | ||
40 | + /** | ||
41 | + * navbarId 对应实体引用 | ||
42 | + */ | ||
43 | + private Navbar navbar; | ||
44 | + /** | ||
45 | + * url | ||
46 | + */ | ||
47 | + private String url; | ||
48 | + /** | ||
49 | + * 0表示停用,1表示启用, 2未认领 | ||
50 | + */ | ||
51 | + private Integer status; | ||
52 | + /** | ||
53 | + * post,get,delete,update | ||
54 | + */ | ||
55 | + private String method; | ||
56 | + | ||
57 | + /** | ||
58 | + * 1表示URL, 2表示API, 3表示FRAGEMENT, 4表示入口地址 | ||
59 | + */ | ||
60 | + private Integer type; | ||
61 | + | ||
62 | + private Iterable<? extends ResourceUrl> resourceUrl; | ||
63 | + | ||
64 | +// public static Resource makeGetResource(Menu menu) { | ||
65 | +// if (menu.getType().equals(Menu.TYPE_DIR) || StringUtils.isBlank(menu.getMenuUrl())) { | ||
66 | +// return null; | ||
67 | +// } | ||
68 | +// Resource obj = new Resource(); | ||
69 | +// obj.setResourceName(menu.getLabel()); | ||
70 | +// obj.setNavbarId(menu.getNavbarId()); | ||
71 | +// obj.setMethod("GET"); | ||
72 | +// obj.setStatus(1); | ||
73 | +// obj.setDescription(menu.getDescription()); | ||
74 | +// obj.setUrl(menu.getMenuUrl()); | ||
75 | +// return obj; | ||
76 | +// } | ||
77 | + | ||
78 | + public void setResourceName (String resourceName){ | ||
79 | + this.resourceName = resourceName; | ||
80 | + } | ||
81 | + public String getResourceName(){ | ||
82 | + return this.resourceName; | ||
83 | + } | ||
84 | + | ||
85 | + public void setDescription (String description){ | ||
86 | + this.description = description; | ||
87 | + } | ||
88 | + public String getDescription(){ | ||
89 | + return this.description; | ||
90 | + } | ||
91 | + | ||
92 | + public void setNavbarId (Long navbarId){ | ||
93 | + this.navbarId = navbarId; | ||
94 | + } | ||
95 | + public Long getNavbarId(){ | ||
96 | + return this.navbarId; | ||
97 | + } | ||
98 | + | ||
99 | + public void setUrl (String url){ | ||
100 | + this.url = url; | ||
101 | + } | ||
102 | + public String getUrl(){ | ||
103 | + return this.url; | ||
104 | + } | ||
105 | + | ||
106 | + public void setStatus (Integer status){ | ||
107 | + this.status = status; | ||
108 | + } | ||
109 | + public Integer getStatus(){ | ||
110 | + return this.status; | ||
111 | + } | ||
112 | + | ||
113 | + public void setMethod (String method){ | ||
114 | + this.method = method; | ||
115 | + } | ||
116 | + public String getMethod(){ | ||
117 | + return this.method; | ||
118 | + } | ||
119 | + | ||
120 | + public Navbar getNavbar() { | ||
121 | + return navbar; | ||
122 | + } | ||
123 | + | ||
124 | + public void setNavbar(Navbar navbar) { | ||
125 | + this.navbar = navbar; | ||
126 | + } | ||
127 | + | ||
128 | + public String getNavbarName() { | ||
129 | + if (navbar == null || navbar.getProjectName() == null) { | ||
130 | + return ""; | ||
131 | + } | ||
132 | + return navbar.getProjectName(); | ||
133 | + } | ||
134 | + | ||
135 | + public Integer getType() { | ||
136 | + return type; | ||
137 | + } | ||
138 | + | ||
139 | + public void setType(Integer type) { | ||
140 | + this.type = type; | ||
141 | + } | ||
142 | + | ||
143 | + public Long getParentId() { | ||
144 | + return parentId; | ||
145 | + } | ||
146 | + | ||
147 | + public void setParentId(Long parentId) { | ||
148 | + this.parentId = parentId; | ||
149 | + } | ||
150 | + | ||
151 | + public String toString(){ | ||
152 | + StringBuffer sb = new StringBuffer(); | ||
153 | + sb.append("Resource ["); | ||
154 | + sb.append("id = "); | ||
155 | + sb.append(id); | ||
156 | + sb.append(", resourceName = "); | ||
157 | + sb.append(resourceName); | ||
158 | + sb.append(", description = "); | ||
159 | + sb.append(description); | ||
160 | + sb.append(", navbarId = "); | ||
161 | + sb.append(navbarId); | ||
162 | + sb.append(", url = "); | ||
163 | + sb.append(url); | ||
164 | + sb.append(", status = "); | ||
165 | + sb.append(status); | ||
166 | + sb.append(", created = "); | ||
167 | + sb.append(created); | ||
168 | + sb.append(", modified = "); | ||
169 | + sb.append(modified); | ||
170 | + sb.append(", method = "); | ||
171 | + sb.append(method); | ||
172 | + sb.append(", type = "); | ||
173 | + sb.append(type); | ||
174 | + sb.append("]"); | ||
175 | + return sb.toString(); | ||
176 | + } | ||
177 | + | ||
178 | + public Iterable<? extends ResourceUrl> getResourceUrl() { | ||
179 | + return resourceUrl; | ||
180 | + } | ||
181 | + | ||
182 | + public void setResourceUrl(Iterable<? extends ResourceUrl> resourceUrl) { | ||
183 | + this.resourceUrl = resourceUrl; | ||
184 | + } | ||
185 | +} | ||
0 | \ No newline at end of file | 186 | \ No newline at end of file |
diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/ResourceUrl.java
0 → 100644
1 | +++ a/diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/ResourceUrl.java | ||
1 | +package com.diligrp.manage.domain; | ||
2 | + | ||
3 | +import com.diligrp.website.util.domain.BaseDomain; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by root on 5/21/15. | ||
7 | + */ | ||
8 | +public class ResourceUrl extends BaseDomain { | ||
9 | + /** | ||
10 | + * 父ID | ||
11 | + */ | ||
12 | + private Long parentId; | ||
13 | + | ||
14 | + /** | ||
15 | + * url | ||
16 | + */ | ||
17 | + private String url; | ||
18 | + | ||
19 | + /** | ||
20 | + * post,get,delete,update | ||
21 | + */ | ||
22 | + private String method; | ||
23 | + | ||
24 | + public ResourceUrl() {} | ||
25 | + | ||
26 | + public ResourceUrl(Long parentId, String url, String method) { | ||
27 | + this.parentId = parentId; | ||
28 | + this.url = url; | ||
29 | + this.method = method; | ||
30 | + } | ||
31 | + | ||
32 | + public ResourceUrl(String url, String method) { | ||
33 | + this.url = url; | ||
34 | + this.method = method; | ||
35 | + } | ||
36 | + | ||
37 | + public Long getParentId() { | ||
38 | + return parentId; | ||
39 | + } | ||
40 | + | ||
41 | + public void setParentId(Long parentId) { | ||
42 | + this.parentId = parentId; | ||
43 | + } | ||
44 | + | ||
45 | + public String getUrl() { | ||
46 | + return url; | ||
47 | + } | ||
48 | + | ||
49 | + public void setUrl(String url) { | ||
50 | + this.url = url; | ||
51 | + } | ||
52 | + | ||
53 | + public String getMethod() { | ||
54 | + return method; | ||
55 | + } | ||
56 | + | ||
57 | + public void setMethod(String method) { | ||
58 | + this.method = method; | ||
59 | + } | ||
60 | + | ||
61 | + @Override | ||
62 | + public String toString() { | ||
63 | + return "ResourceUrl{" + | ||
64 | + "parentId=" + parentId + | ||
65 | + ", url='" + url + '\'' + | ||
66 | + ", method='" + method + '\'' + | ||
67 | + '}'; | ||
68 | + } | ||
69 | +} |
diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/Role.java
0 → 100644
1 | +++ a/diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/Role.java | ||
1 | +package com.diligrp.manage.domain; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | +import com.diligrp.website.util.domain.BaseDomain; | ||
5 | +import java.util.*; | ||
6 | +import java.sql.Timestamp; | ||
7 | + | ||
8 | + | ||
9 | +/** | ||
10 | + * <B>Description</B> <br /> | ||
11 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
12 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
13 | + * <B>Company</B> 地利集团 | ||
14 | + * @createTime 2014-7-3 14:24:41 | ||
15 | + * @author template | ||
16 | + */ | ||
17 | +public class Role extends BaseDomain { | ||
18 | + | ||
19 | + /** | ||
20 | + * 角色名 | ||
21 | + */ | ||
22 | + private String roleName; | ||
23 | + /** | ||
24 | + * 角色描述 | ||
25 | + */ | ||
26 | + private String description; | ||
27 | + | ||
28 | + /** | ||
29 | + * 菜单 | ||
30 | + */ | ||
31 | + private List<Menu> menus; | ||
32 | + private List<? extends Resource> resources = new ArrayList<>(); | ||
33 | + private List<? extends User> users = new ArrayList<>(); | ||
34 | + | ||
35 | + public void setRoleName (String roleName){ | ||
36 | + this.roleName = roleName; | ||
37 | + } | ||
38 | + public String getRoleName(){ | ||
39 | + return this.roleName; | ||
40 | + } | ||
41 | + | ||
42 | + public void setDescription (String description){ | ||
43 | + this.description = description; | ||
44 | + } | ||
45 | + public String getDescription(){ | ||
46 | + return this.description; | ||
47 | + } | ||
48 | + | ||
49 | + public List<Menu> getMenus() { | ||
50 | + return menus; | ||
51 | + } | ||
52 | + | ||
53 | + public void setMenus(List<Menu> menus) { | ||
54 | + this.menus = menus; | ||
55 | + } | ||
56 | + | ||
57 | + public String toString(){ | ||
58 | + StringBuffer sb = new StringBuffer(); | ||
59 | + sb.append("Role ["); | ||
60 | + sb.append("id = "); | ||
61 | + sb.append(id); | ||
62 | + sb.append(", roleName = "); | ||
63 | + sb.append(roleName); | ||
64 | + sb.append(", description = "); | ||
65 | + sb.append(description); | ||
66 | + sb.append(", created = "); | ||
67 | + sb.append(created); | ||
68 | + sb.append(", modified = "); | ||
69 | + sb.append(modified); | ||
70 | + sb.append(", menus = "); | ||
71 | + if(menus != null && !menus.isEmpty()){ | ||
72 | + for (Menu menu : menus) { | ||
73 | + sb.append(menu); | ||
74 | + sb.append(","); | ||
75 | + } | ||
76 | + } | ||
77 | + sb.append("]"); | ||
78 | + sb.append("]"); | ||
79 | + return sb.toString(); | ||
80 | + } | ||
81 | + | ||
82 | + public List<? extends Resource> getResources() { | ||
83 | + return resources; | ||
84 | + } | ||
85 | + | ||
86 | + public void setResources(List<? extends Resource> resources) { | ||
87 | + this.resources = resources; | ||
88 | + } | ||
89 | + | ||
90 | + public List<? extends User> getUsers() { | ||
91 | + return users; | ||
92 | + } | ||
93 | + | ||
94 | + public void setUsers(List<? extends User> users) { | ||
95 | + this.users = users; | ||
96 | + } | ||
97 | +} | ||
0 | \ No newline at end of file | 98 | \ No newline at end of file |
diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/RoleUser.java
0 → 100644
1 | +++ a/diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/RoleUser.java | ||
1 | +package com.diligrp.manage.domain; | ||
2 | + | ||
3 | +import com.diligrp.website.util.domain.BaseDomain; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by root on 4/28/15. | ||
7 | + */ | ||
8 | +public class RoleUser extends BaseDomain { | ||
9 | + @Override | ||
10 | + public String toString() { | ||
11 | + return "RoleUser{" + | ||
12 | + "id=" + id + | ||
13 | + ", userId=" + userId + | ||
14 | + '}'; | ||
15 | + } | ||
16 | + | ||
17 | + private Long id; | ||
18 | + | ||
19 | + private Long userId; | ||
20 | + | ||
21 | + public Long getId() { | ||
22 | + return id; | ||
23 | + } | ||
24 | + | ||
25 | + public void setId(Long id) { | ||
26 | + this.id = id; | ||
27 | + } | ||
28 | + | ||
29 | + public Long getUserId() { | ||
30 | + return userId; | ||
31 | + } | ||
32 | + | ||
33 | + public void setUserId(Long userId) { | ||
34 | + this.userId = userId; | ||
35 | + } | ||
36 | +} |
diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/User.java
0 → 100644
1 | +++ a/diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/User.java | ||
1 | +package com.diligrp.manage.domain; | ||
2 | + | ||
3 | +import com.diligrp.website.util.domain.BaseDomain; | ||
4 | +import java.util.*; | ||
5 | +import java.sql.Timestamp; | ||
6 | + | ||
7 | +/** | ||
8 | + * <B>Description</B> <br /> | ||
9 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
10 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
11 | + * <B>Company</B> 地利集团 | ||
12 | + * | ||
13 | + * @createTime 2014-7-3 14:24:41 | ||
14 | + * @author template | ||
15 | + */ | ||
16 | +public class User extends BaseDomain { | ||
17 | + | ||
18 | + /** | ||
19 | + * 用户名 | ||
20 | + */ | ||
21 | + private String userName; | ||
22 | + /** | ||
23 | + * 密码 | ||
24 | + */ | ||
25 | + private String password; | ||
26 | + | ||
27 | + private String passwordconfirm; | ||
28 | + /** | ||
29 | + * 最后登录ip | ||
30 | + */ | ||
31 | + private String lastLoginIp; | ||
32 | + /** | ||
33 | + * 最后登录时间 | ||
34 | + */ | ||
35 | + private Timestamp lastLoginTime; | ||
36 | + /** | ||
37 | + * 0表示停用,1表示启用 | ||
38 | + */ | ||
39 | + private Integer status; | ||
40 | + /** | ||
41 | + * 真实姓名 | ||
42 | + */ | ||
43 | + private String realName; | ||
44 | + /** | ||
45 | + * 用户编号 | ||
46 | + */ | ||
47 | + private String serialNumber; | ||
48 | + /** | ||
49 | + * 固定电话 | ||
50 | + */ | ||
51 | + private String fixedLineTelephone; | ||
52 | + /** | ||
53 | + * 手机号码 | ||
54 | + */ | ||
55 | + private String cellphone; | ||
56 | + /** | ||
57 | + * 邮箱 | ||
58 | + */ | ||
59 | + private String email; | ||
60 | + /** | ||
61 | + * 有效时间开始点 | ||
62 | + */ | ||
63 | + private Timestamp validTimeBegin; | ||
64 | + | ||
65 | + private String validTimeBeginString; | ||
66 | + /** | ||
67 | + * 有效时间结束点 | ||
68 | + */ | ||
69 | + private Timestamp validTimeEnd; | ||
70 | + | ||
71 | + private String validTimeEndString; | ||
72 | + /** | ||
73 | + * 用户对应的角色 | ||
74 | + */ | ||
75 | + private List<Role> roles; | ||
76 | + | ||
77 | + /** | ||
78 | + * 用户的数据权限 | ||
79 | + */ | ||
80 | + private List<DataAuth> dataAuths; | ||
81 | + | ||
82 | + private String rolesId; | ||
83 | + | ||
84 | + public String getRolesId() { | ||
85 | + return rolesId; | ||
86 | + } | ||
87 | + | ||
88 | + public void setRolesId(String rolesId) { | ||
89 | + this.rolesId = rolesId; | ||
90 | + } | ||
91 | + | ||
92 | + public void setUserName(String userName) { | ||
93 | + this.userName = userName; | ||
94 | + } | ||
95 | + | ||
96 | + public String getUserName() { | ||
97 | + return this.userName; | ||
98 | + } | ||
99 | + | ||
100 | + public void setPassword(String password) { | ||
101 | + this.password = password; | ||
102 | + } | ||
103 | + | ||
104 | + public String getPassword() { | ||
105 | + return this.password; | ||
106 | + } | ||
107 | + | ||
108 | + public String getPasswordconfirm() { | ||
109 | + return passwordconfirm; | ||
110 | + } | ||
111 | + | ||
112 | + public void setPasswordconfirm(String passwordconfirm) { | ||
113 | + this.passwordconfirm = passwordconfirm; | ||
114 | + } | ||
115 | + | ||
116 | + public void setLastLoginIp(String lastLoginIp) { | ||
117 | + this.lastLoginIp = lastLoginIp; | ||
118 | + } | ||
119 | + | ||
120 | + public String getLastLoginIp() { | ||
121 | + return this.lastLoginIp; | ||
122 | + } | ||
123 | + | ||
124 | + public void setLastLoginTime(Timestamp lastLoginTime) { | ||
125 | + this.lastLoginTime = lastLoginTime; | ||
126 | + } | ||
127 | + | ||
128 | + public Timestamp getLastLoginTime() { | ||
129 | + return this.lastLoginTime; | ||
130 | + } | ||
131 | + | ||
132 | + public void setStatus(Integer status) { | ||
133 | + this.status = status; | ||
134 | + } | ||
135 | + | ||
136 | + public Integer getStatus() { | ||
137 | + return this.status; | ||
138 | + } | ||
139 | + | ||
140 | + public void setRealName(String realName) { | ||
141 | + this.realName = realName; | ||
142 | + } | ||
143 | + | ||
144 | + public String getRealName() { | ||
145 | + return this.realName; | ||
146 | + } | ||
147 | + | ||
148 | + public void setSerialNumber(String serialNumber) { | ||
149 | + this.serialNumber = serialNumber; | ||
150 | + } | ||
151 | + | ||
152 | + public String getSerialNumber() { | ||
153 | + return this.serialNumber; | ||
154 | + } | ||
155 | + | ||
156 | + public void setFixedLineTelephone(String fixedLineTelephone) { | ||
157 | + this.fixedLineTelephone = fixedLineTelephone; | ||
158 | + } | ||
159 | + | ||
160 | + public String getFixedLineTelephone() { | ||
161 | + return this.fixedLineTelephone; | ||
162 | + } | ||
163 | + | ||
164 | + public void setCellphone(String cellphone) { | ||
165 | + this.cellphone = cellphone; | ||
166 | + } | ||
167 | + | ||
168 | + public String getCellphone() { | ||
169 | + return this.cellphone; | ||
170 | + } | ||
171 | + | ||
172 | + public void setEmail(String email) { | ||
173 | + this.email = email; | ||
174 | + } | ||
175 | + | ||
176 | + public String getEmail() { | ||
177 | + return this.email; | ||
178 | + } | ||
179 | + | ||
180 | + public void setValidTimeBegin(Timestamp validTimeBegin) { | ||
181 | + this.validTimeBegin = validTimeBegin; | ||
182 | + } | ||
183 | + | ||
184 | + public Timestamp getValidTimeBegin() { | ||
185 | + return this.validTimeBegin; | ||
186 | + } | ||
187 | + | ||
188 | + public void setValidTimeEnd(Timestamp validTimeEnd) { | ||
189 | + this.validTimeEnd = validTimeEnd; | ||
190 | + } | ||
191 | + | ||
192 | + public Timestamp getValidTimeEnd() { | ||
193 | + return this.validTimeEnd; | ||
194 | + } | ||
195 | + | ||
196 | + public List<Role> getRoles() { | ||
197 | + return roles; | ||
198 | + } | ||
199 | + | ||
200 | + public void setRoles(List<Role> roles) { | ||
201 | + this.roles = roles; | ||
202 | + } | ||
203 | + | ||
204 | + public String getRolesString() { | ||
205 | + StringBuffer sb = new StringBuffer(); | ||
206 | + for (Role role : roles) { | ||
207 | + if (sb.length() > 0) { | ||
208 | + sb.append(","); | ||
209 | + } | ||
210 | + sb.append(role.getId()); | ||
211 | + } | ||
212 | + return sb.toString(); | ||
213 | + } | ||
214 | + | ||
215 | + public List<DataAuth> getDataAuths() { | ||
216 | + return dataAuths; | ||
217 | + } | ||
218 | + | ||
219 | + public void setDataAuths(List<DataAuth> dataAuths) { | ||
220 | + this.dataAuths = dataAuths; | ||
221 | + } | ||
222 | + | ||
223 | + public String getValidTimeBeginString() { | ||
224 | + return validTimeBeginString; | ||
225 | + } | ||
226 | + | ||
227 | + public void setValidTimeBeginString(String validTimeBeginString) { | ||
228 | + this.validTimeBeginString = validTimeBeginString; | ||
229 | + } | ||
230 | + | ||
231 | + public String getValidTimeEndString() { | ||
232 | + return validTimeEndString; | ||
233 | + } | ||
234 | + | ||
235 | + public void setValidTimeEndString(String validTimeEndString) { | ||
236 | + this.validTimeEndString = validTimeEndString; | ||
237 | + } | ||
238 | + | ||
239 | + public String toString() { | ||
240 | + StringBuffer sb = new StringBuffer(); | ||
241 | + sb.append("User ["); | ||
242 | + sb.append("id = "); | ||
243 | + sb.append(id); | ||
244 | + sb.append(", userName = "); | ||
245 | + sb.append(userName); | ||
246 | + sb.append(", password = "); | ||
247 | + sb.append(password); | ||
248 | + sb.append(", lastLoginIp = "); | ||
249 | + sb.append(lastLoginIp); | ||
250 | + sb.append(", lastLoginTime = "); | ||
251 | + sb.append(lastLoginTime); | ||
252 | + sb.append(", created = "); | ||
253 | + sb.append(created); | ||
254 | + sb.append(", modified = "); | ||
255 | + sb.append(modified); | ||
256 | + sb.append(", status = "); | ||
257 | + sb.append(status); | ||
258 | + sb.append(", yn = "); | ||
259 | + sb.append(yn); | ||
260 | + sb.append(", realName = "); | ||
261 | + sb.append(realName); | ||
262 | + sb.append(", serialNumber = "); | ||
263 | + sb.append(serialNumber); | ||
264 | + sb.append(", fixedLineTelephone = "); | ||
265 | + sb.append(fixedLineTelephone); | ||
266 | + sb.append(", cellphone = "); | ||
267 | + sb.append(cellphone); | ||
268 | + sb.append(", email = "); | ||
269 | + sb.append(email); | ||
270 | + sb.append(", packUpAddress = "); | ||
271 | + sb.append(", validTimeBegin = "); | ||
272 | + sb.append(validTimeBegin); | ||
273 | + sb.append(", validTimeEnd = "); | ||
274 | + sb.append(validTimeEnd); | ||
275 | + sb.append(", role = "); | ||
276 | + sb.append("["); | ||
277 | + if (roles != null && !roles.isEmpty()) { | ||
278 | + for (Role role : roles) { | ||
279 | + sb.append(role.toString()); | ||
280 | + sb.append(","); | ||
281 | + } | ||
282 | + } | ||
283 | + sb.append("]"); | ||
284 | + sb.append("]"); | ||
285 | + return sb.toString(); | ||
286 | + } | ||
287 | +} | ||
0 | \ No newline at end of file | 288 | \ No newline at end of file |
diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/UserResource.java
0 → 100644
1 | +++ a/diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/UserResource.java | ||
1 | +package com.diligrp.manage.domain; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +public class UserResource implements Serializable{ | ||
6 | + | ||
7 | + private static final long serialVersionUID = 1L; | ||
8 | + | ||
9 | + private long userId ; //用户id | ||
10 | + private String resourceName; //资源名称 | ||
11 | + private String url; //资源url | ||
12 | + private String method; | ||
13 | + | ||
14 | + /** | ||
15 | + * 1表示URL, 2表示API, 3表示FRAGEMENT | ||
16 | + */ | ||
17 | + private Integer type; | ||
18 | + | ||
19 | + public long getUserId() { | ||
20 | + return userId; | ||
21 | + } | ||
22 | + public void setUserId(long userId) { | ||
23 | + this.userId = userId; | ||
24 | + } | ||
25 | + | ||
26 | + public String getResourceName() { | ||
27 | + return resourceName; | ||
28 | + } | ||
29 | + public void setResourceName(String resourceName) { | ||
30 | + this.resourceName = resourceName; | ||
31 | + } | ||
32 | + public String getUrl() { | ||
33 | + return url; | ||
34 | + } | ||
35 | + public void setUrl(String url) { | ||
36 | + this.url = url; | ||
37 | + } | ||
38 | + | ||
39 | + public Integer getType() { | ||
40 | + return type; | ||
41 | + } | ||
42 | + | ||
43 | + public void setType(Integer type) { | ||
44 | + this.type = type; | ||
45 | + } | ||
46 | + | ||
47 | + public String getMethod() { | ||
48 | + return method; | ||
49 | + } | ||
50 | + | ||
51 | + public void setMethod(String method) { | ||
52 | + this.method = method; | ||
53 | + } | ||
54 | +} |
diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/UserRole.java
0 → 100644
1 | +++ a/diligrp-manage-domain/src/main/java/com/diligrp/manage/domain/UserRole.java | ||
1 | +package com.diligrp.manage.domain; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | + | ||
6 | +/** | ||
7 | + * <B>Description</B> <br /> | ||
8 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
9 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
10 | + * <B>Company</B> 地利集团 | ||
11 | + * @createTime 2014-7-3 14:24:39 | ||
12 | + * @author template | ||
13 | + */ | ||
14 | +public class UserRole implements Serializable { | ||
15 | + | ||
16 | + private Long id; | ||
17 | + | ||
18 | + private Long roleId; | ||
19 | + | ||
20 | + public Long getId() { | ||
21 | + return id; | ||
22 | + } | ||
23 | + | ||
24 | + public void setId(Long id) { | ||
25 | + this.id = id; | ||
26 | + } | ||
27 | + | ||
28 | + public Long getRoleId() { | ||
29 | + return roleId; | ||
30 | + } | ||
31 | + | ||
32 | + public void setRoleId(Long roleId) { | ||
33 | + this.roleId = roleId; | ||
34 | + } | ||
35 | + | ||
36 | + | ||
37 | +} | ||
0 | \ No newline at end of file | 38 | \ No newline at end of file |
diligrp-manage-domain/src/main/java/com/diligrp/manage/exception/DiliException.java
0 → 100644
1 | +++ a/diligrp-manage-domain/src/main/java/com/diligrp/manage/exception/DiliException.java | ||
1 | +package com.diligrp.manage.exception; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | +import com.diligrp.website.util.domain.BaseDomain; | ||
5 | +import java.util.*; | ||
6 | +import java.sql.Timestamp; | ||
7 | + | ||
8 | + | ||
9 | +/** | ||
10 | + * <B>Description</B> <br /> | ||
11 | + * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> | ||
12 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
13 | + * <B>Company</B> 地利集团 | ||
14 | + * @createTime 2015-10-4 10:02:14 | ||
15 | + * @author template | ||
16 | + */ | ||
17 | +public class DiliException extends Exception { | ||
18 | + private Map<?, ?> map = null; | ||
19 | + | ||
20 | + public DiliException(){} | ||
21 | + | ||
22 | + public DiliException(String msg){ | ||
23 | + super(msg); | ||
24 | + } | ||
25 | + | ||
26 | + public DiliException(String msg, Map<?, ?> map){ | ||
27 | + super(msg); | ||
28 | + } | ||
29 | + | ||
30 | + | ||
31 | + public Map<?, ?> getMap() { | ||
32 | + return map; | ||
33 | + } | ||
34 | + | ||
35 | + public void setMap(Map<?, ?> map) { | ||
36 | + this.map = map; | ||
37 | + } | ||
38 | +} | ||
0 | \ No newline at end of file | 39 | \ No newline at end of file |
diligrp-manage-manager/.gitignore
0 → 100644
diligrp-manage-manager/pom.xml
0 → 100644
1 | +++ a/diligrp-manage-manager/pom.xml | ||
1 | +<?xml version="1.0"?> | ||
2 | +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
3 | + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
4 | + <modelVersion>4.0.0</modelVersion> | ||
5 | + <parent> | ||
6 | + <groupId>com.b2c.manage</groupId> | ||
7 | + <artifactId>diligrp-manage</artifactId> | ||
8 | + <version>0.0.1-SNAPSHOT</version> | ||
9 | + </parent> | ||
10 | + <groupId>com.b2c.manage.manager</groupId> | ||
11 | + <artifactId>diligrp-manage-manager</artifactId> | ||
12 | + <version>0.0.1-SNAPSHOT</version> | ||
13 | + <packaging>jar</packaging> | ||
14 | + <name>diligrp-manage-manager</name> | ||
15 | + <url>http://maven.apache.org</url> | ||
16 | + <properties> | ||
17 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
18 | + </properties> | ||
19 | + <dependencies> | ||
20 | + <dependency> | ||
21 | + <groupId>com.b2c.manage.dao</groupId> | ||
22 | + <artifactId>diligrp-manage-dao</artifactId> | ||
23 | + <version>0.0.1-SNAPSHOT</version> | ||
24 | + </dependency> | ||
25 | + <dependency> | ||
26 | + <groupId>com.b2c.manage.domain</groupId> | ||
27 | + <artifactId>diligrp-manage-domain</artifactId> | ||
28 | + <version>0.0.1-SNAPSHOT</version> | ||
29 | + </dependency> | ||
30 | + <dependency> | ||
31 | + <groupId>com.b2c.manage</groupId> | ||
32 | + <artifactId>diligrp-manage-sdk</artifactId> | ||
33 | + <version>0.0.3-SNAPSHOT</version> | ||
34 | + </dependency> | ||
35 | + </dependencies> | ||
36 | + <build> | ||
37 | + <finalName>diligrp-manage-manager</finalName> | ||
38 | + </build> | ||
39 | +</project> |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/RedisManager.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/RedisManager.java | ||
1 | +package com.diligrp.manage.manager.customRedis; | ||
2 | + | ||
3 | +import com.diligrp.manage.domain.Role; | ||
4 | +import com.diligrp.manage.domain.User; | ||
5 | + | ||
6 | +/** | ||
7 | + * Created by root on 5/25/15. | ||
8 | + */ | ||
9 | +public interface RedisManager { | ||
10 | + /** | ||
11 | + * 初始化所有URL redis | ||
12 | + */ | ||
13 | + public void initAllUrl(); | ||
14 | + | ||
15 | + /** | ||
16 | + * 删除 用户角色 | ||
17 | + * @param user | ||
18 | + */ | ||
19 | + public Boolean delUser(User user); | ||
20 | + public Boolean delUser(Long userId); | ||
21 | + | ||
22 | + /** | ||
23 | + * 增加 用户角色 | ||
24 | + * @param user | ||
25 | + */ | ||
26 | + public Boolean addUser(User user); | ||
27 | + public Boolean addUser(Long userId); | ||
28 | + | ||
29 | + /** | ||
30 | + * 更新 角色资源 | ||
31 | + * @param roleId | ||
32 | + * @param newResIds | ||
33 | + */ | ||
34 | + public boolean updateRole(Long roleId, Long[] newResIds); | ||
35 | + | ||
36 | + /** | ||
37 | + * 删除角色 | ||
38 | + * @param role | ||
39 | + */ | ||
40 | + public void delRole(Role role); | ||
41 | + | ||
42 | + /** | ||
43 | + * 增加新资源 | ||
44 | + */ | ||
45 | + public boolean addRes(Long parentId); | ||
46 | + | ||
47 | + /** | ||
48 | + * 删除资源 | ||
49 | + */ | ||
50 | + public boolean delRes(Long parentId); | ||
51 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/SessionRedisManager.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/SessionRedisManager.java | ||
1 | +package com.diligrp.manage.manager.customRedis; | ||
2 | + | ||
3 | +import com.diligrp.manage.domain.User; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by root on 5/20/15. | ||
7 | + */ | ||
8 | +public interface SessionRedisManager { | ||
9 | + | ||
10 | + public Long clearSessionUserIdKey(String sessionId); | ||
11 | + | ||
12 | + public Long clearUserIdSessionDataKey(String userId); | ||
13 | + | ||
14 | + public String setSessionUserIdKey(String sessionId, String userId); | ||
15 | + | ||
16 | + public String getSessionUserIdKey(String sessionId); | ||
17 | + | ||
18 | + public String setUserIdSessionDataKey(User userId, String session); | ||
19 | + | ||
20 | + public String getUserIdSessionDataKey(String userId); | ||
21 | + | ||
22 | + public Boolean existUserIdSessionDataKey(String s); | ||
23 | + | ||
24 | + public void addKickSessionKey(String oldSessionId); | ||
25 | + | ||
26 | + public Boolean existKickSessionKey(String oldSessionId); | ||
27 | + | ||
28 | + public void clearKickSessionKey(String oldSessionId); | ||
29 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/MyRedisUtil.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/MyRedisUtil.java | ||
1 | +package com.diligrp.manage.manager.customRedis.impl; | ||
2 | + | ||
3 | +import org.slf4j.Logger; | ||
4 | +import org.slf4j.LoggerFactory; | ||
5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
6 | +import org.springframework.stereotype.Component; | ||
7 | +import redis.clients.jedis.Jedis; | ||
8 | +import redis.clients.jedis.JedisPool; | ||
9 | + | ||
10 | +import java.util.List; | ||
11 | +import java.util.Set; | ||
12 | + | ||
13 | +/** | ||
14 | + * Created by root on 5/21/15. | ||
15 | + */ | ||
16 | +@Component | ||
17 | +public class MyRedisUtil { | ||
18 | + // TODO: 所有的redis常量返回值,给出一个异常类型 | ||
19 | + | ||
20 | + private Logger log = LoggerFactory.getLogger(MyRedisUtil.class); | ||
21 | + | ||
22 | + public JedisPool getJedisPool() { | ||
23 | + return jedisPool; | ||
24 | + } | ||
25 | + | ||
26 | + // 需要使用 redis set求并集,不可使用 redis客户端集群 | ||
27 | + @Autowired | ||
28 | + private JedisPool jedisPool; | ||
29 | + | ||
30 | + | ||
31 | + // 工具操作 | ||
32 | +// /** | ||
33 | +// * 为了大量redis value String的装换工具 | ||
34 | +// * | ||
35 | +// * @param lStr List<String> 或 List<Long> | ||
36 | +// * @return 转换结果 | ||
37 | +// */ | ||
38 | +// private String[] convertListToStrArray(List<Object> lStr) { | ||
39 | +// String[] sArray = new String[lStr.size()]; | ||
40 | +// for(int i=0; i<sArray.length; i++) { | ||
41 | +// if(lStr.get(i) != null) { | ||
42 | +// sArray[i] = lStr.get(i).toString(); | ||
43 | +// } | ||
44 | +// } | ||
45 | +// return sArray; | ||
46 | +// } | ||
47 | + | ||
48 | + private String[] convertLongToStrArray(Long[] longs) { | ||
49 | + String[] sArray = new String[longs.length]; | ||
50 | + for(int i=0; i<longs.length; i++) { | ||
51 | + sArray[i] = String.valueOf(longs[i]); | ||
52 | + } | ||
53 | + return sArray; | ||
54 | + } | ||
55 | + | ||
56 | + // 集合操作 | ||
57 | + /** | ||
58 | + * 获取集合值 | ||
59 | + */ | ||
60 | + public Set<String> setGet(String key) { | ||
61 | + Set<String> rst = null; | ||
62 | + Jedis jedis = null; | ||
63 | + try { | ||
64 | + jedis = jedisPool.getResource(); | ||
65 | + rst = jedis.smembers(key); | ||
66 | + } catch (Exception e) { | ||
67 | + log.info("保存 key - "+key+" 失败", e); | ||
68 | + } finally { | ||
69 | + if (jedis != null) { | ||
70 | + jedisPool.returnResource(jedis); | ||
71 | + } | ||
72 | + } | ||
73 | + return rst; | ||
74 | + } | ||
75 | + | ||
76 | + | ||
77 | + /** | ||
78 | + * 写入redis缓存set集合 - keyId: [valueId1, valueId2, ...] | ||
79 | + * @param key redis key | ||
80 | + * @param LValue List<String> 或 List<Long> | ||
81 | + * @return | ||
82 | + */ | ||
83 | + public Long setAdd(String key, List<String> LValue) { | ||
84 | + Long rst = setAdd(key, LValue.toArray(new String[0])); | ||
85 | + return rst; | ||
86 | + } | ||
87 | + | ||
88 | + public Long setAdd(String key, Long[] LValue) { | ||
89 | + Long rst = null; | ||
90 | + String[] strValue = convertLongToStrArray(LValue); | ||
91 | + rst = setAdd(key, strValue); | ||
92 | + return rst; | ||
93 | + } | ||
94 | + | ||
95 | + /** | ||
96 | + * 写入redis缓存set集合 - keyId: [valueId1, valueId2, ...] | ||
97 | + * @param key | ||
98 | + * @param value 只是类型问题 | ||
99 | + * @return | ||
100 | + */ | ||
101 | + public Long setAdd(String key, String[] value) { | ||
102 | + Long rst = null; | ||
103 | + | ||
104 | + Jedis jedis = null; | ||
105 | + try { | ||
106 | + if(value.length != 0) { | ||
107 | + jedis = jedisPool.getResource(); | ||
108 | + rst = jedis.sadd(key, value); | ||
109 | + } | ||
110 | + } catch (Exception e) { | ||
111 | + log.info("保存 key - "+key+" 失败", e); | ||
112 | + } finally { | ||
113 | + if (jedis != null) { | ||
114 | + jedisPool.returnResource(jedis); | ||
115 | + } | ||
116 | + } | ||
117 | + return rst; | ||
118 | + } | ||
119 | + | ||
120 | + /** | ||
121 | + * 写入redis缓存set集合 - keyId: [valueId1, valueId2, ...] | ||
122 | + * @param key | ||
123 | + * @param value 只是类型问题 | ||
124 | + * @return | ||
125 | + */ | ||
126 | + public Long setAdd(String key, String value) { | ||
127 | + Long rst = null; | ||
128 | + | ||
129 | + Jedis jedis = null; | ||
130 | + try { | ||
131 | + jedis = jedisPool.getResource(); | ||
132 | + rst = jedis.sadd(key, value); | ||
133 | + } catch (Exception e) { | ||
134 | + log.info("保存 key - "+key+" 失败", e); | ||
135 | + } finally { | ||
136 | + if (jedis != null) { | ||
137 | + jedisPool.returnResource(jedis); | ||
138 | + } | ||
139 | + } | ||
140 | + return rst; | ||
141 | + } | ||
142 | + | ||
143 | + | ||
144 | + /** | ||
145 | + * 判断指定set集合的key元素是否存在 | ||
146 | + * @param key | ||
147 | + * @return | ||
148 | + */ | ||
149 | + public boolean isMemberKey(String key, String member) { | ||
150 | + boolean rst = false; | ||
151 | + | ||
152 | + Jedis jedis = null; | ||
153 | + try { | ||
154 | + jedis = jedisPool.getResource(); | ||
155 | + rst = jedis.sismember(key, member); | ||
156 | + } catch (Exception e) { | ||
157 | + log.info("查找 key - "+key+" 中元素 - "+member+" 失败", e); | ||
158 | + } finally { | ||
159 | + if (jedis != null) { | ||
160 | + jedisPool.returnResource(jedis); | ||
161 | + } | ||
162 | + } | ||
163 | + return rst; | ||
164 | + } | ||
165 | + | ||
166 | + /** | ||
167 | + * 判断指定set集合的key元素 删除 | ||
168 | + * @param key | ||
169 | + * @return | ||
170 | + */ | ||
171 | + public Long setRomoveMemberKey(String key, String member) { | ||
172 | + Long rst = null; | ||
173 | + | ||
174 | + Jedis jedis = null; | ||
175 | + try { | ||
176 | + jedis = jedisPool.getResource(); | ||
177 | + rst = jedis.srem(key, member); | ||
178 | + } catch (Exception e) { | ||
179 | + log.info("查找 key - "+key+" 中元素 - "+member+" 失败", e); | ||
180 | + } finally { | ||
181 | + if (jedis != null) { | ||
182 | + jedisPool.returnResource(jedis); | ||
183 | + } | ||
184 | + } | ||
185 | + return rst; | ||
186 | + } | ||
187 | + /** | ||
188 | + * 判断指定set集合的key元素 删除 | ||
189 | + * @param key | ||
190 | + * @return | ||
191 | + */ | ||
192 | + public Long setScard(String key) { | ||
193 | + Long rst = null; | ||
194 | + | ||
195 | + Jedis jedis = null; | ||
196 | + try { | ||
197 | + jedis = jedisPool.getResource(); | ||
198 | + rst = jedis.scard(key); | ||
199 | + } catch (Exception e) { | ||
200 | + log.info("查找 key - "+key+" 个数失败", e); | ||
201 | + } finally { | ||
202 | + if (jedis != null) { | ||
203 | + jedisPool.returnResource(jedis); | ||
204 | + } | ||
205 | + } | ||
206 | + return rst; | ||
207 | + } | ||
208 | + | ||
209 | + | ||
210 | + /** | ||
211 | + * 集合求并集,然后转存 | ||
212 | + * @param desKey 目标存储key | ||
213 | + * @param memberKeys 并集member keys | ||
214 | + * @return | ||
215 | + */ | ||
216 | + public Long setUnionStore(String desKey, List<String> memberKeys) { | ||
217 | + return setUnionStore(desKey, memberKeys.toArray(new String[0])); | ||
218 | + } | ||
219 | + | ||
220 | + public Long setUnionStore(String desKey, String[] memberKeys) { | ||
221 | + Long rst = null; | ||
222 | + Jedis jedis = null; | ||
223 | + try { | ||
224 | + jedis = jedisPool.getResource(); | ||
225 | + rst = jedis.sunionstore(desKey, memberKeys); | ||
226 | + } catch (Exception e) { | ||
227 | + log.info("并集 memberKeys" + memberKeys + " 到 - desKey" + desKey + " 失败", e); | ||
228 | + } finally { | ||
229 | + if (jedis != null) { | ||
230 | + jedisPool.returnResource(jedis); | ||
231 | + } | ||
232 | + } | ||
233 | + return rst; | ||
234 | + } | ||
235 | + | ||
236 | + /** | ||
237 | + * 差集 | ||
238 | + * @param aDiffb | ||
239 | + * @param memberDiffs | ||
240 | + * @return | ||
241 | + */ | ||
242 | + public Long setDiffStore(String aDiffb, String[] memberDiffs) { | ||
243 | + Long rst = null; | ||
244 | + Jedis jedis = null; | ||
245 | + try { | ||
246 | + jedis = jedisPool.getResource(); | ||
247 | + rst = jedis.sdiffstore(aDiffb, memberDiffs); | ||
248 | + } catch (Exception e) { | ||
249 | + log.info("差集 memberDiffs" + memberDiffs + " 到 - aDiffb" + aDiffb + " 失败", e); | ||
250 | + } finally { | ||
251 | + if (jedis != null) { | ||
252 | + jedisPool.returnResource(jedis); | ||
253 | + } | ||
254 | + } | ||
255 | + return rst; | ||
256 | + } | ||
257 | + | ||
258 | + // 共同操作 | ||
259 | + /** | ||
260 | + * 检查key是否存在 | ||
261 | + * @param key | ||
262 | + * @return | ||
263 | + */ | ||
264 | + public boolean keyExist(String key) { | ||
265 | + boolean rst = false; | ||
266 | + | ||
267 | + Jedis jedis = null; | ||
268 | + try { | ||
269 | + jedis = jedisPool.getResource(); | ||
270 | + rst = jedis.exists(key); | ||
271 | + } catch (Exception e) { | ||
272 | + log.info("检查 key - "+key+" 失败", e); | ||
273 | + } finally { | ||
274 | + if (jedis != null) { | ||
275 | + jedisPool.returnResource(jedis); | ||
276 | + } | ||
277 | + } | ||
278 | + return rst; | ||
279 | + } | ||
280 | + | ||
281 | + /** | ||
282 | + * 删除指定key | ||
283 | + * @param key | ||
284 | + * @return | ||
285 | + */ | ||
286 | + public Long delKey(String key) { | ||
287 | + Long rst = null; | ||
288 | + | ||
289 | + Jedis jedis = null; | ||
290 | + try { | ||
291 | + jedis = jedisPool.getResource(); | ||
292 | + rst = jedis.del(key); | ||
293 | + } catch (Exception e) { | ||
294 | + log.info("删除 key - "+key+" 失败", e); | ||
295 | + } finally { | ||
296 | + if (jedis != null) { | ||
297 | + jedisPool.returnResource(jedis); | ||
298 | + } | ||
299 | + } | ||
300 | + return rst; | ||
301 | + } | ||
302 | + | ||
303 | + public Set<String> keys(String key_pattern) { | ||
304 | + Set<String> rst = null; | ||
305 | + Jedis jedis = null; | ||
306 | + try { | ||
307 | + jedis = jedisPool.getResource(); | ||
308 | + rst =jedis.keys(key_pattern); | ||
309 | + } catch (Exception e) { | ||
310 | + log.info("查询 key pattern - "+ key_pattern +" 失败", e); | ||
311 | + } finally { | ||
312 | + if (jedis != null) { | ||
313 | + jedisPool.returnResource(jedis); | ||
314 | + } | ||
315 | + } | ||
316 | + return rst; | ||
317 | + } | ||
318 | + | ||
319 | + | ||
320 | + // 字符串操作 | ||
321 | + /** | ||
322 | + * 根据key获取字符串信息 | ||
323 | + * | ||
324 | + * @param key 存储key | ||
325 | + * @return 如果返回空,则未获取到数据或抛出异常 | ||
326 | + */ | ||
327 | + public String getString(String key) { | ||
328 | + Jedis jedis = null; | ||
329 | + try { | ||
330 | + jedis = jedisPool.getResource(); | ||
331 | + return jedis.get(key); | ||
332 | + } catch (Exception e) { | ||
333 | + log.info("getString,获取字符串失败", e); | ||
334 | + return null; | ||
335 | + } finally { | ||
336 | + if (jedis != null) { | ||
337 | + jedisPool.returnResource(jedis); | ||
338 | + } | ||
339 | + } | ||
340 | + } | ||
341 | + | ||
342 | + /** | ||
343 | + * 根据key获取字符串信息 | ||
344 | + * | ||
345 | + * @param key 存储key | ||
346 | + * @param value 存储key | ||
347 | + * @return 如果返回空,则未获取到数据或抛出异常 | ||
348 | + */ | ||
349 | + public String setString(String key, String value) { | ||
350 | + Jedis jedis = null; | ||
351 | + String rst = null; | ||
352 | + try { | ||
353 | + jedis = jedisPool.getResource(); | ||
354 | + rst = jedis.set(key, value); | ||
355 | + } catch (Exception e) { | ||
356 | + log.info("getString,获取字符串失败", e); | ||
357 | + return null; | ||
358 | + } finally { | ||
359 | + if (jedis != null) { | ||
360 | + jedisPool.returnResource(jedis); | ||
361 | + } | ||
362 | + } | ||
363 | + return rst; | ||
364 | + } | ||
365 | + | ||
366 | + /** | ||
367 | + * 写入redis缓存set集合 - keyId: [valueId1, valueId2, ...] | ||
368 | + * @param key | ||
369 | + * @param value 只是类型问题 | ||
370 | + * @return | ||
371 | + */ | ||
372 | + public String setStringByExpire(String key, String value, Integer sessionTimeOut) { | ||
373 | + String rst = null; | ||
374 | + | ||
375 | + Jedis jedis = null; | ||
376 | + try { | ||
377 | + jedis = jedisPool.getResource(); | ||
378 | + rst =jedis.setex(key, sessionTimeOut, value); | ||
379 | + } catch (Exception e) { | ||
380 | + log.info("保存 key - "+key+" 失败", e); | ||
381 | + } finally { | ||
382 | + if (jedis != null) { | ||
383 | + jedisPool.returnResource(jedis); | ||
384 | + } | ||
385 | + } | ||
386 | + return rst; | ||
387 | + } | ||
388 | + | ||
389 | + | ||
390 | + /** | ||
391 | + * 获取多个string值 | ||
392 | + * @param keys | ||
393 | + * @return | ||
394 | + */ | ||
395 | + public List<String> getManyString(List<String> keys) { | ||
396 | + return getManyString(keys.toArray(new String[0])); | ||
397 | + } | ||
398 | + | ||
399 | + public List<String> getManyString(String[] keys) { | ||
400 | + Jedis jedis = null; | ||
401 | + try { | ||
402 | + jedis = jedisPool.getResource(); | ||
403 | + return jedis.mget(keys); | ||
404 | + } catch (Exception e) { | ||
405 | + log.info("getString,获取字符串失败", e); | ||
406 | + return null; | ||
407 | + } finally { | ||
408 | + if (jedis != null) { | ||
409 | + jedisPool.returnResource(jedis); | ||
410 | + } | ||
411 | + } | ||
412 | + } | ||
413 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/RedisMangerImpl.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/RedisMangerImpl.java | ||
1 | +package com.diligrp.manage.manager.customRedis.impl; | ||
2 | + | ||
3 | +import com.diligrp.manage.domain.Resource; | ||
4 | +import com.diligrp.manage.domain.Role; | ||
5 | +import com.diligrp.manage.domain.User; | ||
6 | +import com.diligrp.manage.manager.customRedis.RedisManager; | ||
7 | +import com.diligrp.manage.manager.customRedis.impl.redis.RedisRHManage; | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | +import org.springframework.stereotype.Component; | ||
10 | + | ||
11 | +import java.util.ArrayList; | ||
12 | +import java.util.List; | ||
13 | + | ||
14 | +/** | ||
15 | + * Created by root on 5/25/15. | ||
16 | + */ | ||
17 | +@Component | ||
18 | +public class RedisMangerImpl implements RedisManager { | ||
19 | + @Autowired | ||
20 | + private RedisRHManage redisRHManage; | ||
21 | + | ||
22 | + @Override | ||
23 | + public void initAllUrl() { | ||
24 | + redisRHManage.initAllUrl(); | ||
25 | + } | ||
26 | + | ||
27 | + @Override | ||
28 | + public Boolean delUser(User user) { | ||
29 | + // user为新修改用户,不可直接改变 | ||
30 | + User t = new User(); | ||
31 | + t.setId(user.getId()); | ||
32 | + redisRHManage.delUser(t); | ||
33 | + return true; | ||
34 | + } | ||
35 | + | ||
36 | + @Override | ||
37 | + public Boolean delUser(Long userId) { | ||
38 | + User t = new User(); | ||
39 | + t.setId(userId); | ||
40 | + redisRHManage.delUser(t); | ||
41 | + return true; | ||
42 | + } | ||
43 | + | ||
44 | + @Override | ||
45 | + public Boolean addUser(User user) { | ||
46 | + redisRHManage.addUser(user); | ||
47 | + return false; | ||
48 | + } | ||
49 | + | ||
50 | + @Override | ||
51 | + public Boolean addUser(Long userId) { | ||
52 | + User t = new User(); | ||
53 | + t.setId(userId); | ||
54 | + redisRHManage.addUser(t); | ||
55 | + return false; | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public boolean updateRole(Long roleId, Long[] newResIds) { | ||
60 | + Role role = new Role(); | ||
61 | + role.setId(roleId); | ||
62 | + List<Resource> ress = new ArrayList<>(); | ||
63 | + for (Long id : newResIds) { | ||
64 | + Resource r = new Resource(); | ||
65 | + r.setId(id); | ||
66 | + ress.add(r); | ||
67 | + } | ||
68 | + redisRHManage.updateRole(role); | ||
69 | + return false; | ||
70 | + } | ||
71 | + | ||
72 | + @Override | ||
73 | + public void delRole(Role role) { | ||
74 | + redisRHManage.delRole(role); | ||
75 | + } | ||
76 | + | ||
77 | + @Override | ||
78 | + public boolean addRes(Long parentId) { | ||
79 | + Resource res = new Resource(); | ||
80 | + res.setId(parentId); | ||
81 | + redisRHManage.addRes(res); | ||
82 | + return false; | ||
83 | + } | ||
84 | + | ||
85 | + @Override | ||
86 | + public boolean delRes(Long parentId) { | ||
87 | + Resource res = new Resource(); | ||
88 | + res.setId(parentId); | ||
89 | + redisRHManage.delRes(res); | ||
90 | + return true; | ||
91 | + } | ||
92 | + | ||
93 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/SessionRedisManagerImpl.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/SessionRedisManagerImpl.java | ||
1 | +package com.diligrp.manage.manager.customRedis.impl; | ||
2 | + | ||
3 | +import com.diligrp.manage.domain.User; | ||
4 | +import com.diligrp.manage.manager.customRedis.SessionRedisManager; | ||
5 | +import com.diligrp.manage.sdk.session.SessionConstants; | ||
6 | +import org.nutz.json.Json; | ||
7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
8 | +import org.springframework.stereotype.Component; | ||
9 | + | ||
10 | +import java.util.HashMap; | ||
11 | +import java.util.Map; | ||
12 | + | ||
13 | +/** | ||
14 | + * Created by root on 5/20/15. | ||
15 | + */ | ||
16 | +@Component | ||
17 | +public class SessionRedisManagerImpl implements SessionRedisManager { | ||
18 | + | ||
19 | + public static final String SESSION = "sessionId"; | ||
20 | + | ||
21 | + @Autowired | ||
22 | + private MyRedisUtil myRedisUtil; | ||
23 | + | ||
24 | + public String setUserIdSessionDataKey(User user, String session) { | ||
25 | + Map<String, String> map = new HashMap<String, String>(); | ||
26 | + map.put("sessionId", session); | ||
27 | + map.put("user", Json.toJson(user)); | ||
28 | + return myRedisUtil.setStringByExpire(SessionConstants.USERID_SESSION_KEY + user.getId(), | ||
29 | + Json.toJson(map), SessionConstants.SESSIONID_USERID_TIMEOUT); | ||
30 | + } | ||
31 | + | ||
32 | + public String getUserIdSessionDataKey(String userId) { | ||
33 | + return myRedisUtil.getString(SessionConstants.USERID_SESSION_KEY + userId); | ||
34 | + } | ||
35 | + | ||
36 | + @Override | ||
37 | + public Boolean existUserIdSessionDataKey(String s) { | ||
38 | + return myRedisUtil.keyExist(SessionConstants.USERID_SESSION_KEY + s); | ||
39 | + } | ||
40 | + | ||
41 | + @Override | ||
42 | + public void addKickSessionKey(String oldSessionId) { | ||
43 | + myRedisUtil.setStringByExpire(SessionConstants.KICK_OLDSESSIONID_KEY + oldSessionId, | ||
44 | + "", SessionConstants.COOKIE_TIMEOUT); | ||
45 | + } | ||
46 | + | ||
47 | + @Override | ||
48 | + public Boolean existKickSessionKey(String oldSessionId) { | ||
49 | + return myRedisUtil.keyExist(SessionConstants.KICK_OLDSESSIONID_KEY + oldSessionId); | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public void clearKickSessionKey(String oldSessionId) { | ||
54 | + myRedisUtil.delKey(SessionConstants.KICK_OLDSESSIONID_KEY + oldSessionId); | ||
55 | + } | ||
56 | + | ||
57 | + // sessionId - userId 操作 - START | ||
58 | + public String setSessionUserIdKey(String sessionId, String userId) { | ||
59 | + String rst = null; | ||
60 | + rst = myRedisUtil.setStringByExpire(SessionConstants.SESSION_USERID_KEY + sessionId, | ||
61 | + userId, SessionConstants.SESSIONID_USERID_TIMEOUT); | ||
62 | + return rst; | ||
63 | + } | ||
64 | + | ||
65 | + public String getSessionUserIdKey(String sessionId) { | ||
66 | + String rst = null; | ||
67 | + rst = myRedisUtil.getString(SessionConstants.SESSION_USERID_KEY + sessionId); | ||
68 | + return rst; | ||
69 | + } | ||
70 | + | ||
71 | + public Long clearSessionUserIdKey(String sessionId) { | ||
72 | + Long rst = null; | ||
73 | + rst = myRedisUtil.delKey(SessionConstants.SESSION_USERID_KEY + sessionId); | ||
74 | + return rst; | ||
75 | + } | ||
76 | + | ||
77 | + @Override | ||
78 | + public Long clearUserIdSessionDataKey(String userId) { | ||
79 | + return myRedisUtil.delKey(SessionConstants.USERID_SESSION_KEY + userId); | ||
80 | + } | ||
81 | + // sessionId - userId 操作 - END | ||
82 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/AllUrlRH.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/AllUrlRH.java | ||
1 | +package com.diligrp.manage.manager.customRedis.impl.redis; | ||
2 | + | ||
3 | +import com.diligrp.manage.dao.ResourceUrlDao; | ||
4 | +import com.diligrp.manage.domain.Resource; | ||
5 | +import com.diligrp.manage.domain.ResourceUrl; | ||
6 | +import com.diligrp.manage.manager.customRedis.impl.MyRedisUtil; | ||
7 | +import com.diligrp.manage.sdk.session.SessionConstants; | ||
8 | +import com.diligrp.website.util.dao.BaseQuery; | ||
9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
10 | +import org.springframework.stereotype.Component; | ||
11 | + | ||
12 | +import java.util.ArrayList; | ||
13 | +import java.util.List; | ||
14 | + | ||
15 | +/** | ||
16 | + * Created by Administrator on 2015/5/23. | ||
17 | + */ | ||
18 | +@Component | ||
19 | +public class AllUrlRH implements RedisHandle<Object> { | ||
20 | + | ||
21 | + @Autowired | ||
22 | + private MyRedisUtil myRedisUtil; | ||
23 | + | ||
24 | + @Autowired | ||
25 | + private RedisRHManage redisRHManage; | ||
26 | + | ||
27 | + @Autowired | ||
28 | + private ResourceUrlDao resourceUrlDao; | ||
29 | + | ||
30 | + public AllUrlRH(RedisRHManage redisRHManage, MyRedisUtil myRedisUtil, ResourceUrlDao resourceUrlDao){ | ||
31 | + this.redisRHManage = redisRHManage; | ||
32 | + this.myRedisUtil = myRedisUtil; | ||
33 | + this.resourceUrlDao = resourceUrlDao; | ||
34 | + } | ||
35 | + | ||
36 | + @Override | ||
37 | + public Object initByRedis(Object obj) { | ||
38 | + return null; | ||
39 | + } | ||
40 | + | ||
41 | + @Override | ||
42 | + public void save(Object obj) { | ||
43 | + if (myRedisUtil.keyExist(SessionConstants.ALL_RES_KEY)) { | ||
44 | + return; | ||
45 | + } | ||
46 | + // 获取所有的res url | ||
47 | + List<ResourceUrl> res = resourceUrlDao.listAll(); | ||
48 | + List<String> resGrpKeyList = new ArrayList<>(); | ||
49 | + for (ResourceUrl url : res) { | ||
50 | + String resGrpKey = SessionConstants.RES_GRP_KEY + url.getParentId(); | ||
51 | + myRedisUtil.setAdd(resGrpKey, formatUrl(url)); | ||
52 | + resGrpKeyList.add(resGrpKey); | ||
53 | + | ||
54 | + // url->grpId | ||
55 | + redisRHManage.addResUrl(url); | ||
56 | + } | ||
57 | + myRedisUtil.setUnionStore(SessionConstants.ALL_RES_KEY, resGrpKeyList); | ||
58 | + } | ||
59 | + | ||
60 | + @Override | ||
61 | + public void del(Object id) { | ||
62 | + | ||
63 | + } | ||
64 | + | ||
65 | + @Override | ||
66 | + public void reload(Object obj) { | ||
67 | + | ||
68 | + } | ||
69 | + | ||
70 | + private String formatUrl(ResourceUrl res) { | ||
71 | + StringBuilder tempUrl = new StringBuilder(); | ||
72 | + tempUrl.append('[').append(res.getMethod()).append(']').append(res.getUrl().replace("http://", "")); | ||
73 | + return tempUrl.toString(); | ||
74 | + } | ||
75 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/RedisHandle.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/RedisHandle.java | ||
1 | +package com.diligrp.manage.manager.customRedis.impl.redis; | ||
2 | + | ||
3 | +/** | ||
4 | + * Created by Administrator on 2015/5/23. | ||
5 | + */ | ||
6 | +public interface RedisHandle<T> { | ||
7 | + | ||
8 | + /** | ||
9 | + * 根据redis初始化对象 | ||
10 | + * @param obj | ||
11 | + * @return | ||
12 | + */ | ||
13 | + public T initByRedis(T obj); | ||
14 | + | ||
15 | + public void save(T obj); | ||
16 | + | ||
17 | + public void del(T obj); | ||
18 | + | ||
19 | + /** | ||
20 | + * 重新加载相关数据 | ||
21 | + * @param obj | ||
22 | + */ | ||
23 | + public void reload(T obj); | ||
24 | + | ||
25 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/RedisRHManage.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/RedisRHManage.java | ||
1 | +package com.diligrp.manage.manager.customRedis.impl.redis; | ||
2 | + | ||
3 | +import com.diligrp.manage.dao.DataAuthDao; | ||
4 | +import com.diligrp.manage.dao.ResourceDao; | ||
5 | +import com.diligrp.manage.dao.ResourceUrlDao; | ||
6 | +import com.diligrp.manage.dao.RoleDao; | ||
7 | +import com.diligrp.manage.dao.UserDao; | ||
8 | +import com.diligrp.manage.domain.DataAuth; | ||
9 | +import com.diligrp.manage.domain.Resource; | ||
10 | +import com.diligrp.manage.domain.ResourceUrl; | ||
11 | +import com.diligrp.manage.domain.Role; | ||
12 | +import com.diligrp.manage.domain.User; | ||
13 | +import com.diligrp.manage.manager.customRedis.impl.MyRedisUtil; | ||
14 | +import com.diligrp.website.util.dao.BaseQuery; | ||
15 | +import org.springframework.beans.factory.annotation.Autowired; | ||
16 | +import org.springframework.stereotype.Component; | ||
17 | + | ||
18 | +import java.util.ArrayList; | ||
19 | +import java.util.List; | ||
20 | + | ||
21 | +/** | ||
22 | + * Created by Administrator on 2015/5/23. | ||
23 | + */ | ||
24 | +@Component | ||
25 | +public class RedisRHManage { | ||
26 | + | ||
27 | + @Autowired | ||
28 | + private RoleDao roleDao; | ||
29 | + @Autowired | ||
30 | + private ResourceDao resourceDao; | ||
31 | + | ||
32 | + @Autowired | ||
33 | + private UserDao userDao; | ||
34 | + | ||
35 | + @Autowired | ||
36 | + private ResourceUrlDao resourceUrlDao; | ||
37 | + | ||
38 | + @Autowired | ||
39 | + private DataAuthDao dataAuthDao; | ||
40 | + | ||
41 | + | ||
42 | + @Autowired | ||
43 | + private MyRedisUtil myRedisUtil; | ||
44 | + | ||
45 | + private ResourceUrlRH resourceUrlRH; | ||
46 | + private ResourceRH resourceRH; | ||
47 | + private AllUrlRH allUrlRH; | ||
48 | + private RoleRH roleRH; | ||
49 | + | ||
50 | + | ||
51 | + private UserRH userRH; | ||
52 | + | ||
53 | + | ||
54 | + public void addResUrl(ResourceUrl resUrl) { | ||
55 | + getResourceUrlRH().save(resUrl); | ||
56 | + } | ||
57 | + | ||
58 | + public void delResUrl(ResourceUrl resUrl) { | ||
59 | + getResourceUrlRH().del(resUrl); | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
63 | + * 初始化所有URL | ||
64 | + */ | ||
65 | + public void initAllUrl(){ | ||
66 | + getAllUrlRH().save(null); | ||
67 | + } | ||
68 | + | ||
69 | + public void delRes(Resource res){ | ||
70 | + getResourceRH().del(fetchResourceUrl(res)); | ||
71 | + } | ||
72 | + | ||
73 | + public void addRes(Resource res){ | ||
74 | + getResourceRH().save(fetchResourceUrl(res)); | ||
75 | + } | ||
76 | + | ||
77 | + public void updateRes(Resource res){ | ||
78 | + delRes(res); | ||
79 | + addRes(res); | ||
80 | + } | ||
81 | + | ||
82 | + private Resource fetchResourceUrl(Resource res){ | ||
83 | + List<ResourceUrl> resUrls = resourceUrlDao.listByResourceID(res.getId()); | ||
84 | + res.setResourceUrl(resUrls); | ||
85 | + return res; | ||
86 | + } | ||
87 | + | ||
88 | + public void delRole(Role role){ | ||
89 | + getRoleRH().del(fetchRole(role)); | ||
90 | + } | ||
91 | + | ||
92 | + public void addRole(Role role){ | ||
93 | + getRoleRH().save(fetchRole(role)); | ||
94 | + } | ||
95 | + | ||
96 | + public void updateRole(Role role){ | ||
97 | + delRole(role); | ||
98 | + addRole(role); | ||
99 | + } | ||
100 | + | ||
101 | + public void reloadRole(Role role) { | ||
102 | + getRoleRH().reload(fetchRole(role)); | ||
103 | + } | ||
104 | + | ||
105 | + private Role fetchRole(Role role){ | ||
106 | + List<User> userRolesList = userDao.findUserByRole(role.getId()); | ||
107 | + role.setUsers(userRolesList); | ||
108 | + List<Resource> resources = resourceDao.findByRole(role.getId()); | ||
109 | + role.setResources(resources); | ||
110 | + return role; | ||
111 | + } | ||
112 | + | ||
113 | + public void delUser(User user) { | ||
114 | + getUserRH().del(fetchUser(user)); | ||
115 | + } | ||
116 | + | ||
117 | + public void addUser(User user) { | ||
118 | + getUserRH().save(fetchUser(user)); | ||
119 | + } | ||
120 | + | ||
121 | + public void updateUser(User user){ | ||
122 | + delUser(user); | ||
123 | + addUser(user); | ||
124 | + } | ||
125 | + public void reloadUser(User user) { | ||
126 | + getUserRH().reload(fetchUser(user)); | ||
127 | + } | ||
128 | + | ||
129 | + private User fetchUser(User user) { | ||
130 | + List<Role> roles = roleDao.findByUserId(user.getId()); | ||
131 | + List<DataAuth> dataAuths = dataAuthDao.findByUser(user.getId()); | ||
132 | + user.setDataAuths(dataAuths); | ||
133 | + user.setRoles(roles); | ||
134 | + return user; | ||
135 | + } | ||
136 | + | ||
137 | + | ||
138 | + | ||
139 | + public UserRH getUserRH() { | ||
140 | + if(this.userRH == null) { | ||
141 | + userRH = new UserRH(this, myRedisUtil); | ||
142 | + } | ||
143 | + return userRH; | ||
144 | + } | ||
145 | + | ||
146 | + public RoleRH getRoleRH() { | ||
147 | + if(this.roleRH == null) { | ||
148 | + roleRH = new RoleRH(this, myRedisUtil); | ||
149 | + } | ||
150 | + return roleRH; | ||
151 | + } | ||
152 | + | ||
153 | + public AllUrlRH getAllUrlRH() { | ||
154 | + if(this.allUrlRH == null) { | ||
155 | + allUrlRH = new AllUrlRH(this, myRedisUtil, resourceUrlDao); | ||
156 | + } | ||
157 | + return allUrlRH; | ||
158 | + } | ||
159 | + | ||
160 | + public ResourceRH getResourceRH() { | ||
161 | + if(this.resourceRH == null) { | ||
162 | + resourceRH = new ResourceRH(this, myRedisUtil); | ||
163 | + } | ||
164 | + return resourceRH; | ||
165 | + } | ||
166 | + | ||
167 | + public ResourceUrlRH getResourceUrlRH() { | ||
168 | + if(this.resourceUrlRH == null) { | ||
169 | + resourceUrlRH = new ResourceUrlRH(myRedisUtil); | ||
170 | + } | ||
171 | + return resourceUrlRH; | ||
172 | + } | ||
173 | + | ||
174 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/RedisRHManage2.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/RedisRHManage2.java | ||
1 | +package com.diligrp.manage.manager.customRedis.impl.redis; | ||
2 | + | ||
3 | +import com.diligrp.manage.dao.ResourceDao; | ||
4 | +import com.diligrp.manage.dao.ResourceUrlDao; | ||
5 | +import com.diligrp.manage.dao.RoleDao; | ||
6 | +import com.diligrp.manage.dao.UserDao; | ||
7 | +import com.diligrp.manage.domain.Resource; | ||
8 | +import com.diligrp.manage.domain.ResourceUrl; | ||
9 | +import com.diligrp.manage.domain.Role; | ||
10 | +import com.diligrp.manage.domain.User; | ||
11 | +import com.diligrp.website.util.dao.BaseQuery; | ||
12 | +import org.springframework.beans.factory.annotation.Autowired; | ||
13 | +import org.springframework.stereotype.Component; | ||
14 | + | ||
15 | +import java.util.ArrayList; | ||
16 | +import java.util.List; | ||
17 | + | ||
18 | +/** | ||
19 | + * Created by Administrator on 2015/5/23. | ||
20 | + */ | ||
21 | +@Component | ||
22 | +public class RedisRHManage2 { | ||
23 | + | ||
24 | + @Autowired | ||
25 | + private RoleDao roleDao; | ||
26 | + @Autowired | ||
27 | + private ResourceDao resourceDao; | ||
28 | + | ||
29 | + @Autowired | ||
30 | + private UserDao userDao; | ||
31 | + | ||
32 | + @Autowired | ||
33 | + private ResourceUrlDao resourceUrlDao; | ||
34 | + | ||
35 | + @Autowired | ||
36 | + private ResourceRH resourceRH; | ||
37 | + @Autowired | ||
38 | + private AllUrlRH allUrlRH; | ||
39 | + @Autowired | ||
40 | + private RoleRH roleRH; | ||
41 | + @Autowired | ||
42 | + private UserRH userRH; | ||
43 | + | ||
44 | + /** | ||
45 | + * 初始化所有URL | ||
46 | + */ | ||
47 | + public void initAllUrl(){ | ||
48 | + allUrlRH.save(null); | ||
49 | + } | ||
50 | + | ||
51 | + public void delRes(Resource res){ | ||
52 | + resourceRH.del(fetchResourceUrl(res)); | ||
53 | + } | ||
54 | + | ||
55 | + public void addRes(Resource res){ | ||
56 | + resourceRH.save(fetchResourceUrl(res)); | ||
57 | + } | ||
58 | + | ||
59 | + public void updateRes(Resource res){ | ||
60 | + delRes(res); | ||
61 | + addRes(res); | ||
62 | + } | ||
63 | + | ||
64 | + private Resource fetchResourceUrl(Resource res){ | ||
65 | + BaseQuery bq = new BaseQuery(); | ||
66 | + bq.addParam("parentId", res.getId().toString()); | ||
67 | + List<ResourceUrl> resUrls = resourceUrlDao.listByCondition(bq); | ||
68 | + res.setResourceUrl(resUrls); | ||
69 | + return res; | ||
70 | + } | ||
71 | + | ||
72 | + public void delRole(Role role) { | ||
73 | + roleRH.del(fetchRole(role)); | ||
74 | + } | ||
75 | + | ||
76 | + public void addRole(Role role){ | ||
77 | + roleRH.save(fetchRole(role)); | ||
78 | + } | ||
79 | + | ||
80 | + public void updateRole(Role role) { | ||
81 | + delRole(role); | ||
82 | + addRole(role); | ||
83 | + } | ||
84 | + | ||
85 | + public void reloadRole(Role role) { | ||
86 | + roleRH.reload(role); | ||
87 | + } | ||
88 | + | ||
89 | + private Role fetchRole(Role role){ | ||
90 | + List<User> userRolesList = userDao.findUserByRole(role.getId()); | ||
91 | + role.setUsers(userRolesList); | ||
92 | + List<Resource> resources = resourceDao.findByRole(role.getId()); | ||
93 | + role.setResources(resources); | ||
94 | + return role; | ||
95 | + } | ||
96 | + | ||
97 | + public void delUser(User user) { | ||
98 | + userRH.del(fetchUser(user)); | ||
99 | + } | ||
100 | + | ||
101 | + public void addUser(User user) { | ||
102 | + userRH.save(fetchUser(user)); | ||
103 | + } | ||
104 | + | ||
105 | + public void updateUser(User user){ | ||
106 | + delUser(user); | ||
107 | + addUser(user); | ||
108 | + } | ||
109 | + | ||
110 | + private User fetchUser(User user) { | ||
111 | + List<Role> roles = roleDao.findByUserId(user.getId()); | ||
112 | + user.setRoles(roles); | ||
113 | + return user; | ||
114 | + } | ||
115 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/ResourceRH.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/ResourceRH.java | ||
1 | +package com.diligrp.manage.manager.customRedis.impl.redis; | ||
2 | + | ||
3 | +import com.diligrp.manage.domain.Resource; | ||
4 | +import com.diligrp.manage.domain.ResourceUrl; | ||
5 | +import com.diligrp.manage.domain.Role; | ||
6 | +import com.diligrp.manage.manager.customRedis.impl.MyRedisUtil; | ||
7 | +import com.diligrp.manage.sdk.session.SessionConstants; | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | + | ||
10 | +import java.util.ArrayList; | ||
11 | +import java.util.List; | ||
12 | +import java.util.Set; | ||
13 | + | ||
14 | +/** | ||
15 | + * RH:redis handle | ||
16 | + * Created by Administrator on 2015/5/23. | ||
17 | + */ | ||
18 | +//@Component | ||
19 | +public class ResourceRH implements RedisHandle<Resource>{ | ||
20 | + | ||
21 | + @Autowired | ||
22 | + private MyRedisUtil myRedisUtil; | ||
23 | + | ||
24 | + private RedisRHManage redisRHManage; | ||
25 | + | ||
26 | + | ||
27 | + public ResourceRH(RedisRHManage redisRHManage, MyRedisUtil myRedisUtil) { | ||
28 | + this.myRedisUtil = myRedisUtil; | ||
29 | + this.redisRHManage = redisRHManage; | ||
30 | + } | ||
31 | + | ||
32 | + @Override | ||
33 | + public Resource initByRedis(Resource obj) { | ||
34 | + return null; | ||
35 | + } | ||
36 | + | ||
37 | + /** | ||
38 | + * allUrl | ||
39 | + * url->resID | ||
40 | + * reID->url | ||
41 | + * @param obj | ||
42 | + */ | ||
43 | + public void save(Resource obj){ | ||
44 | + String resGrpKey = SessionConstants.RES_GRP_KEY + obj.getId(); | ||
45 | + String allUrlKey = SessionConstants.ALL_RES_KEY; | ||
46 | + List<String> urls = new ArrayList<>(); | ||
47 | + for (ResourceUrl url : obj.getResourceUrl()) { | ||
48 | + String u = formatUrl(url); | ||
49 | + urls.add(u); | ||
50 | + redisRHManage.addResUrl(url); | ||
51 | +// resourceUrlRH.save(url); | ||
52 | + } | ||
53 | + | ||
54 | + myRedisUtil.setAdd(resGrpKey, urls); | ||
55 | + myRedisUtil.setAdd(allUrlKey, urls); | ||
56 | + | ||
57 | + String resRoleKey = SessionConstants.RES_ROLE_KEY + obj.getId(); | ||
58 | + Set<String> roles = myRedisUtil.setGet(resRoleKey); | ||
59 | + for (String id : roles) { | ||
60 | + Role role = new Role(); | ||
61 | + role.setId(Long.valueOf(id)); | ||
62 | + redisRHManage.updateRole(role); | ||
63 | + } | ||
64 | + } | ||
65 | + | ||
66 | + public void del(Resource obj){ | ||
67 | + String resUrl = SessionConstants.RES_GRP_KEY + obj.getId(); | ||
68 | + myRedisUtil.delKey(resUrl); | ||
69 | + | ||
70 | + String resRoleKey = SessionConstants.RES_ROLE_KEY + obj.getId(); | ||
71 | + Set<String> roles = myRedisUtil.setGet(resRoleKey); | ||
72 | + for (String id : roles) { | ||
73 | + Role role = new Role(); | ||
74 | + role.setId(Long.valueOf(id)); | ||
75 | + redisRHManage.updateRole(role); | ||
76 | + } | ||
77 | + | ||
78 | + for(ResourceUrl ru : obj.getResourceUrl()) { | ||
79 | +// resourceUrlRH.del(ru); | ||
80 | + redisRHManage.delResUrl(ru); | ||
81 | + } | ||
82 | + } | ||
83 | + | ||
84 | + @Override | ||
85 | + public void reload(Resource obj) { | ||
86 | + | ||
87 | + } | ||
88 | + | ||
89 | + private String formatUrl(ResourceUrl res) { | ||
90 | + StringBuilder tempUrl = new StringBuilder(); | ||
91 | + tempUrl.append('[').append(res.getMethod()).append(']').append(res.getUrl().replace("http://", "")); | ||
92 | + return tempUrl.toString(); | ||
93 | + } | ||
94 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/ResourceUrlRH.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/ResourceUrlRH.java | ||
1 | +package com.diligrp.manage.manager.customRedis.impl.redis; | ||
2 | + | ||
3 | +import com.diligrp.manage.domain.ResourceUrl; | ||
4 | +import com.diligrp.manage.manager.customRedis.impl.MyRedisUtil; | ||
5 | +import com.diligrp.manage.sdk.session.SessionConstants; | ||
6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
7 | + | ||
8 | +/** | ||
9 | + * RH:redis handle | ||
10 | + * Created by Administrator on 2015/5/23. | ||
11 | + */ | ||
12 | +//@Component | ||
13 | +public class ResourceUrlRH implements RedisHandle<ResourceUrl>{ | ||
14 | + | ||
15 | + @Autowired | ||
16 | + private MyRedisUtil myRedisUtil; | ||
17 | + | ||
18 | + public ResourceUrlRH(MyRedisUtil myRedisUtil) { | ||
19 | + this.myRedisUtil = myRedisUtil; | ||
20 | + } | ||
21 | + | ||
22 | + private String formatUrl(ResourceUrl res) { | ||
23 | + StringBuilder tempUrl = new StringBuilder(); | ||
24 | + tempUrl.append('[').append(res.getMethod()).append(']').append(res.getUrl().replace("http://", "")); | ||
25 | + return tempUrl.toString(); | ||
26 | + } | ||
27 | + | ||
28 | + @Override | ||
29 | + public ResourceUrl initByRedis(ResourceUrl obj) { | ||
30 | + return null; | ||
31 | + } | ||
32 | + | ||
33 | + @Override | ||
34 | + public void save(ResourceUrl obj) { | ||
35 | + String url = formatUrl(obj); | ||
36 | + String urlGrpKey = SessionConstants.URL_RESGRP_KEY + url; | ||
37 | + myRedisUtil.setAdd(urlGrpKey, obj.getParentId().toString()); | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public void del(ResourceUrl obj) { | ||
42 | + String url = formatUrl(obj); | ||
43 | + String urlRes = SessionConstants.URL_RESGRP_KEY + url; | ||
44 | + myRedisUtil.setRomoveMemberKey(urlRes, obj.getParentId().toString()); | ||
45 | + | ||
46 | + if(myRedisUtil.setScard(urlRes) == 0) { | ||
47 | + //删除全部URL中的某个URL | ||
48 | + myRedisUtil.setRomoveMemberKey(SessionConstants.ALL_RES_KEY, url); | ||
49 | + } | ||
50 | + } | ||
51 | + | ||
52 | + | ||
53 | + @Override | ||
54 | + public void reload(ResourceUrl obj) { | ||
55 | + | ||
56 | + } | ||
57 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/RoleRH.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/RoleRH.java | ||
1 | +package com.diligrp.manage.manager.customRedis.impl.redis; | ||
2 | + | ||
3 | +import com.diligrp.manage.domain.Resource; | ||
4 | +import com.diligrp.manage.domain.Role; | ||
5 | +import com.diligrp.manage.domain.User; | ||
6 | +import com.diligrp.manage.manager.customRedis.impl.MyRedisUtil; | ||
7 | +import com.diligrp.manage.sdk.session.SessionConstants; | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | + | ||
10 | +import java.util.ArrayList; | ||
11 | +import java.util.List; | ||
12 | + | ||
13 | +/** | ||
14 | + * Created by Administrator on 2015/5/23. | ||
15 | + */ | ||
16 | +//@Component | ||
17 | +public class RoleRH implements RedisHandle<Role>{ | ||
18 | + | ||
19 | + @Autowired | ||
20 | + private MyRedisUtil myRedisUtil; | ||
21 | + | ||
22 | + @Autowired | ||
23 | + private RedisRHManage redisRHManage; | ||
24 | + | ||
25 | + public RoleRH(RedisRHManage redisRHManage, MyRedisUtil myRedisUtil) { | ||
26 | + this.redisRHManage = redisRHManage; | ||
27 | + this.myRedisUtil = myRedisUtil; | ||
28 | + } | ||
29 | + | ||
30 | + /** | ||
31 | + * role->url | ||
32 | + * role->user | ||
33 | + * | ||
34 | + * @param obj | ||
35 | + */ | ||
36 | + @Override | ||
37 | + public Role initByRedis(Role obj) { | ||
38 | + return null; | ||
39 | + } | ||
40 | + | ||
41 | + @Override | ||
42 | + public void save(Role obj) { | ||
43 | + reload(obj, true); | ||
44 | + } | ||
45 | + | ||
46 | + @Override | ||
47 | + public void del(Role obj) { | ||
48 | + // role->res | ||
49 | + String roleRes = SessionConstants.ROLE_RES_KEY + obj.getId(); | ||
50 | + myRedisUtil.delKey(roleRes); | ||
51 | + | ||
52 | + // role->user | ||
53 | + String roleUser = SessionConstants.ROLE_USER_KEY + obj.getId(); | ||
54 | + myRedisUtil.delKey(roleUser); | ||
55 | + | ||
56 | + for (Resource re : obj.getResources()) { | ||
57 | + String resRoleKey = SessionConstants.RES_ROLE_KEY + re.getId(); | ||
58 | + myRedisUtil.setRomoveMemberKey(resRoleKey, obj.getId().toString()); | ||
59 | + } | ||
60 | + | ||
61 | + updateUser(obj); | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public void reload(Role obj) { | ||
66 | + reload(obj, false); | ||
67 | + } | ||
68 | + | ||
69 | + | ||
70 | + private void reload(Role obj, Boolean notify) { | ||
71 | + // role->url | ||
72 | + if(obj.getResources() != null && obj.getResources().size() > 0) { | ||
73 | + String roleRes = SessionConstants.ROLE_RES_KEY + obj.getId(); | ||
74 | + List<String> ress = new ArrayList<>(); | ||
75 | + // url->grp | ||
76 | + for (Resource re : obj.getResources()) { | ||
77 | + String resKey = SessionConstants.RES_GRP_KEY + re.getId(); | ||
78 | + ress.add(resKey); | ||
79 | + // res->role | ||
80 | + String resRoleKey = SessionConstants.RES_ROLE_KEY + re.getId(); | ||
81 | + myRedisUtil.setAdd(resRoleKey, obj.getId().toString()); | ||
82 | + } | ||
83 | + myRedisUtil.setUnionStore(roleRes, ress); | ||
84 | + } | ||
85 | + | ||
86 | + // role->user | ||
87 | + if(obj.getUsers() != null && obj.getUsers().size() > 0) { | ||
88 | + String roleUser = SessionConstants.ROLE_USER_KEY + obj.getId(); | ||
89 | + List<Long> users = new ArrayList<>(); | ||
90 | + for (User u : obj.getUsers()) { | ||
91 | + users.add(u.getId()); | ||
92 | + } | ||
93 | + myRedisUtil.setAdd(roleUser, users.toArray(new Long[0])); | ||
94 | + if(notify) { | ||
95 | + updateUser(obj); | ||
96 | + } | ||
97 | + } | ||
98 | + } | ||
99 | + | ||
100 | + /** | ||
101 | + * 更新用户 | ||
102 | + * @param obj | ||
103 | + */ | ||
104 | + private void updateUser(Role obj) { | ||
105 | + if(obj.getUsers() != null && obj.getUsers().size() > 0) { | ||
106 | + for (User u : obj.getUsers()) { | ||
107 | + redisRHManage.reloadUser(u); | ||
108 | + } | ||
109 | + } | ||
110 | + } | ||
111 | + | ||
112 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/UserRH.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/customRedis/impl/redis/UserRH.java | ||
1 | +package com.diligrp.manage.manager.customRedis.impl.redis; | ||
2 | + | ||
3 | +import com.diligrp.manage.domain.DataAuth; | ||
4 | +import com.diligrp.manage.domain.Role; | ||
5 | +import com.diligrp.manage.domain.User; | ||
6 | +import com.diligrp.manage.manager.customRedis.impl.MyRedisUtil; | ||
7 | +import com.diligrp.manage.sdk.session.SessionConstants; | ||
8 | +import org.nutz.json.Json; | ||
9 | +import org.nutz.lang.meta.Pair; | ||
10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
11 | + | ||
12 | +import java.util.ArrayList; | ||
13 | +import java.util.HashMap; | ||
14 | +import java.util.List; | ||
15 | +import java.util.Map; | ||
16 | +import java.util.Set; | ||
17 | + | ||
18 | +/** | ||
19 | + * Created by Administrator on 2015/5/23. | ||
20 | + */ | ||
21 | +//@Component | ||
22 | +public class UserRH implements RedisHandle<User> { | ||
23 | + @Autowired | ||
24 | + private MyRedisUtil myRedisUtil; | ||
25 | + | ||
26 | + @Autowired | ||
27 | + private RedisRHManage redisRHManage; | ||
28 | + | ||
29 | + public UserRH(RedisRHManage redisRHManage, MyRedisUtil myRedisUtil) { | ||
30 | + this.redisRHManage = redisRHManage; | ||
31 | + this.myRedisUtil = myRedisUtil; | ||
32 | + } | ||
33 | + | ||
34 | + @Override | ||
35 | + public User initByRedis(User obj) { | ||
36 | + return null; | ||
37 | + } | ||
38 | + | ||
39 | + /** | ||
40 | + * user->role | ||
41 | + * role->url | ||
42 | + * user->url | ||
43 | + * @param obj | ||
44 | + */ | ||
45 | + @Override | ||
46 | + public void save(User obj) { | ||
47 | + reload(obj, true); | ||
48 | + } | ||
49 | + | ||
50 | + @Override | ||
51 | + public void del(User obj) { | ||
52 | + // user->role | ||
53 | + String userRole = SessionConstants.USER_ROLES_KEY + obj.getId(); | ||
54 | + myRedisUtil.delKey(userRole); | ||
55 | + | ||
56 | + // user->res | ||
57 | + String userRes = SessionConstants.USER_RESURL_KEY + obj.getId(); | ||
58 | + myRedisUtil.delKey(userRes); | ||
59 | + | ||
60 | + // role->user | ||
61 | + for (Role r : obj.getRoles()) { | ||
62 | + String roleUserKey = SessionConstants.ROLE_USER_KEY + r.getId(); | ||
63 | + myRedisUtil.setRomoveMemberKey(roleUserKey, obj.getId().toString()); | ||
64 | + } | ||
65 | + | ||
66 | + | ||
67 | + String userDataAuth = SessionConstants.USER_DATAAUTH_KEY + obj.getId(); | ||
68 | + Set<String> keys = myRedisUtil.keys(userDataAuth + "*"); | ||
69 | + for (String key : keys) { | ||
70 | + myRedisUtil.delKey(key); | ||
71 | + } | ||
72 | + } | ||
73 | + | ||
74 | + @Override | ||
75 | + public void reload(User obj) { | ||
76 | + reload(obj, false); | ||
77 | + } | ||
78 | + | ||
79 | + private void reload(User obj, Boolean notify) { | ||
80 | + del(obj); | ||
81 | + reloadRole(obj, notify); | ||
82 | + reloadDataAuth(obj, notify); | ||
83 | + } | ||
84 | + | ||
85 | + /** | ||
86 | + * 加载角色权限 | ||
87 | + * @param obj | ||
88 | + * @param notify | ||
89 | + */ | ||
90 | + private void reloadRole(User obj, Boolean notify){ | ||
91 | + if (obj.getRoles() == null || obj.getRoles().size() == 0) { | ||
92 | + return; | ||
93 | + } | ||
94 | + | ||
95 | + List<Long> roles = new ArrayList<>(); | ||
96 | + List<String> roleRes = new ArrayList<>(); | ||
97 | + for (Role r : obj.getRoles()) { | ||
98 | + roles.add(r.getId()); | ||
99 | + roleRes.add(SessionConstants.ROLE_RES_KEY + r.getId()); | ||
100 | + // role->url | ||
101 | + if(notify) { | ||
102 | + redisRHManage.reloadRole(r); | ||
103 | + } | ||
104 | + } | ||
105 | + // user->role | ||
106 | + String userRole = SessionConstants.USER_ROLES_KEY + obj.getId(); | ||
107 | + myRedisUtil.setAdd(userRole, roles.toArray(new Long[0])); | ||
108 | + // user->url | ||
109 | + String userRes = SessionConstants.USER_RESURL_KEY + obj.getId(); | ||
110 | + myRedisUtil.setUnionStore(userRes, roleRes); | ||
111 | + } | ||
112 | + | ||
113 | + /** | ||
114 | + * 加载数据权限 | ||
115 | + * @param obj | ||
116 | + * @param notify | ||
117 | + */ | ||
118 | + private void reloadDataAuth(User obj, Boolean notify) { | ||
119 | + | ||
120 | + String key = SessionConstants.USER_DATAAUTH_KEY + obj.getId(); | ||
121 | + for (Map.Entry<String, List<String>> entry : fetchDas(obj).entrySet()) { | ||
122 | + myRedisUtil.setAdd(key + ":" + entry.getKey(), entry.getValue().toArray(new String[0])); | ||
123 | + } | ||
124 | + } | ||
125 | + | ||
126 | + private Map<String, List<String>> fetchDas(User obj){ | ||
127 | + Map<String, List<String>> das = new HashMap<>(); | ||
128 | + for (DataAuth d : obj.getDataAuths()) { | ||
129 | + List<String> list = das.get(d.getType()); | ||
130 | + if (list == null) { | ||
131 | + list = new ArrayList<>(); | ||
132 | + das.put(d.getType(), list); | ||
133 | + } | ||
134 | + Pair<String> p = new Pair<>(); | ||
135 | + p.setName(d.getDataId()); | ||
136 | + p.setValue(d.getLabel()); | ||
137 | + list.add(Json.toJson(p)); | ||
138 | + } | ||
139 | + return das; | ||
140 | + } | ||
141 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/dataAuth/DataAuthManager.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/dataAuth/DataAuthManager.java | ||
1 | +package com.diligrp.manage.manager.dataAuth; | ||
2 | + | ||
3 | +import java.util.List; | ||
4 | + | ||
5 | +import com.diligrp.manage.domain.DataAuth; | ||
6 | +import com.diligrp.website.util.dao.BaseQuery; | ||
7 | +import com.diligrp.website.util.web.PageTemplate; | ||
8 | + | ||
9 | +/** | ||
10 | + * <B>Description</B> <br /> | ||
11 | + * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. | ||
12 | + * <br /> | ||
13 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
14 | + * <B>Company</B> 地利集团 | ||
15 | + * | ||
16 | + * @createTime 2015-10-4 10:02:14 | ||
17 | + * @author template | ||
18 | + */ | ||
19 | +public interface DataAuthManager { | ||
20 | + | ||
21 | + public PageTemplate find(BaseQuery bq); | ||
22 | + | ||
23 | + public DataAuth findOne(Long pk); | ||
24 | + | ||
25 | + public Boolean save(DataAuth dataAuth, List<DataAuth> datas); | ||
26 | + | ||
27 | + public Boolean update(DataAuth dataAuth); | ||
28 | + | ||
29 | + public Boolean del(Long id); | ||
30 | + | ||
31 | + public List<DataAuth> findByType(Long userId, String type); | ||
32 | + | ||
33 | + public DataAuth findByData(Long userId, String type, String dataAuth); | ||
34 | + | ||
35 | + public List<DataAuth> findbyParent(String type, String parentId, Long userId); | ||
36 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/dataAuth/DataAuthManagerImpl.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/dataAuth/DataAuthManagerImpl.java | ||
1 | +package com.diligrp.manage.manager.dataAuth; | ||
2 | + | ||
3 | +import java.util.List; | ||
4 | + | ||
5 | +import org.slf4j.Logger; | ||
6 | +import org.slf4j.LoggerFactory; | ||
7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
8 | +import org.springframework.cache.annotation.CacheEvict; | ||
9 | +import org.springframework.cache.annotation.Cacheable; | ||
10 | +import org.springframework.stereotype.Component; | ||
11 | + | ||
12 | +import com.diligrp.manage.dao.DataAuthDao; | ||
13 | +import com.diligrp.manage.domain.DataAuth; | ||
14 | +import com.diligrp.website.util.dao.BaseQuery; | ||
15 | +import com.diligrp.website.util.web.PageTemplate; | ||
16 | + | ||
17 | +/** | ||
18 | + * <B>Description</B> <br /> | ||
19 | + * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. | ||
20 | + * <br /> | ||
21 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
22 | + * <B>Company</B> 地利集团 | ||
23 | + * | ||
24 | + * @createTime 2015-10-4 10:02:14 | ||
25 | + * @author template | ||
26 | + */ | ||
27 | +@Component | ||
28 | +public class DataAuthManagerImpl implements DataAuthManager { | ||
29 | + private final static Logger LOG = LoggerFactory.getLogger(DataAuthManagerImpl.class); | ||
30 | + | ||
31 | + @Autowired | ||
32 | + private DataAuthDao dataAuthDao; | ||
33 | + | ||
34 | + public PageTemplate find(BaseQuery bq) { | ||
35 | + List<DataAuth> list = dataAuthDao.listByCondition(bq); | ||
36 | + int totalSize = dataAuthDao.countByCondition(bq); | ||
37 | + return PageTemplate.create(bq, totalSize, list); | ||
38 | + } | ||
39 | + | ||
40 | + @Cacheable(value = "rc", key = "'diligrp-manage:dataAuth:id:' + #id", unless = "#result==null") | ||
41 | + public DataAuth findOne(Long id) { | ||
42 | + return dataAuthDao.getById(id); | ||
43 | + } | ||
44 | + | ||
45 | + @Override | ||
46 | + public Boolean save(DataAuth dataAuth, List<DataAuth> datas) { | ||
47 | + List<DataAuth> list = findByType(dataAuth.getUserId(), dataAuth.getType()); | ||
48 | + for (DataAuth da : list) { | ||
49 | + dataAuthDao.deleteById(da.getId()); | ||
50 | + } | ||
51 | + // if (dataAuth.getDataId() != null && | ||
52 | + // dataAuth.getDataId().equals("-1")) { | ||
53 | + // dataAuth.setLabel("全部"); | ||
54 | + // dataAuthDao.save(dataAuth); | ||
55 | + // return true; | ||
56 | + // } | ||
57 | + for (DataAuth obj : datas) { | ||
58 | + dataAuthDao.save(obj); | ||
59 | + } | ||
60 | + return true; | ||
61 | + } | ||
62 | + | ||
63 | + @CacheEvict(value = "rc", key = "'diligrp-manage:dataAuth:id:' + #dataAuth.getId()") | ||
64 | + public Boolean update(DataAuth dataAuth) { | ||
65 | + return dataAuthDao.update(dataAuth); | ||
66 | + } | ||
67 | + | ||
68 | + @CacheEvict(value = "rc", key = "'diligrp-manage:dataAuth:id:' + #id") | ||
69 | + public Boolean del(Long id) { | ||
70 | + return dataAuthDao.deleteById(id); | ||
71 | + } | ||
72 | + | ||
73 | + @Override | ||
74 | + public List<DataAuth> findByType(Long userId, String type) { | ||
75 | + return dataAuthDao.findByType(userId, type); | ||
76 | + } | ||
77 | + | ||
78 | + @Override | ||
79 | + public DataAuth findByData(Long userId, String type, String dataAuth) { | ||
80 | + return dataAuthDao.findByData(userId, type, dataAuth); | ||
81 | + } | ||
82 | + | ||
83 | + @Override | ||
84 | + public List<DataAuth> findbyParent(String type, String parentId, Long userId) { | ||
85 | + return this.dataAuthDao.findByParentDataId(parentId, type, userId); | ||
86 | + } | ||
87 | + | ||
88 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/menu/MenuManager.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/menu/MenuManager.java | ||
1 | +package com.diligrp.manage.manager.menu; | ||
2 | + | ||
3 | +import com.diligrp.manage.domain.Menu; | ||
4 | +import com.diligrp.manage.domain.MenuJson; | ||
5 | +import com.diligrp.website.util.dao.BaseQuery; | ||
6 | +import com.diligrp.website.util.web.PageTemplate; | ||
7 | +import org.springframework.transaction.annotation.Transactional; | ||
8 | + | ||
9 | +import java.util.List; | ||
10 | + | ||
11 | +/** | ||
12 | + * <B>Description</B> <br /> | ||
13 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
14 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
15 | + * <B>Company</B> 地利集团 | ||
16 | + * @createTime 2014-7-3 14:24:39 | ||
17 | + * @author template | ||
18 | + */ | ||
19 | +public interface MenuManager { | ||
20 | + | ||
21 | + /** | ||
22 | + * 获取所有菜单的树结构 | ||
23 | + * @return | ||
24 | + */ | ||
25 | + public List<Menu> fetchAllTree(); | ||
26 | + /** | ||
27 | + * 根据用户ID获取菜单 | ||
28 | + * @param id | ||
29 | + * @return | ||
30 | + */ | ||
31 | + public List<Menu> findByUserId(Long id); | ||
32 | + | ||
33 | + public List<Menu> findByRole(Long id); | ||
34 | + | ||
35 | + /** | ||
36 | + * 根据父节点查询菜单 | ||
37 | + * @param id | ||
38 | + * @return | ||
39 | + */ | ||
40 | + public List<Menu> findByParent(Long id); | ||
41 | + | ||
42 | + /** | ||
43 | + * 满足条件的总数 | ||
44 | + * @param bq | ||
45 | + * @return | ||
46 | + */ | ||
47 | + public Integer count(BaseQuery bq); | ||
48 | + | ||
49 | + public PageTemplate find(BaseQuery bq); | ||
50 | + | ||
51 | + public Menu findOne(Long pk); | ||
52 | + | ||
53 | + @Transactional | ||
54 | + public Boolean save(Menu menu); | ||
55 | + | ||
56 | + public Boolean update(Menu menu); | ||
57 | + | ||
58 | + /** | ||
59 | + * 根据系统删除菜单 | ||
60 | + * @param id | ||
61 | + * @return | ||
62 | + */ | ||
63 | + public Boolean delByNavbar(Long id); | ||
64 | + @Transactional | ||
65 | + public Boolean del(Long id); | ||
66 | + | ||
67 | + @Transactional | ||
68 | + public void sort(Menu menu); | ||
69 | + public void move(Menu menu); | ||
70 | + public List<MenuJson> findAllMenuJson(); | ||
71 | + public Integer countAllChild(Long parentId); | ||
72 | + | ||
73 | + public List<Menu> findAll(); | ||
74 | + | ||
75 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/menu/impl/MenuManagerImpl.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/menu/impl/MenuManagerImpl.java | ||
1 | +package com.diligrp.manage.manager.menu.impl; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSON; | ||
4 | +import com.diligrp.manage.domain.MenuJson; | ||
5 | +import com.diligrp.manage.domain.Resource; | ||
6 | +import com.diligrp.manage.domain.Role; | ||
7 | +import com.diligrp.manage.manager.menu.MenuManager; | ||
8 | +import com.diligrp.manage.manager.navbar.NavbarManager; | ||
9 | +import com.diligrp.manage.manager.resource.ResourceManager; | ||
10 | +import com.diligrp.manage.manager.role.RoleManager; | ||
11 | +import com.diligrp.website.util.redis.RedisUtil; | ||
12 | +import org.slf4j.Logger; | ||
13 | +import org.slf4j.LoggerFactory; | ||
14 | +import org.springframework.beans.factory.annotation.Autowired; | ||
15 | +import org.springframework.stereotype.Component; | ||
16 | + | ||
17 | +import com.diligrp.manage.dao.MenuDao; | ||
18 | +import com.diligrp.manage.domain.Menu; | ||
19 | +import com.diligrp.website.util.dao.BaseQuery; | ||
20 | +import com.diligrp.website.util.web.PageTemplate; | ||
21 | + | ||
22 | + | ||
23 | +import java.util.*; | ||
24 | + | ||
25 | +/** | ||
26 | + * <B>Description</B> <br /> | ||
27 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
28 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
29 | + * <B>Company</B> 地利集团 | ||
30 | + * @createTime 2014-7-3 14:24:39 | ||
31 | + * @author template | ||
32 | + */ | ||
33 | +@Component | ||
34 | +public class MenuManagerImpl implements MenuManager { | ||
35 | + private final static Logger LOG = LoggerFactory | ||
36 | + .getLogger(MenuManagerImpl.class); | ||
37 | + | ||
38 | + /** | ||
39 | + * 缓存菜单KEY | ||
40 | + */ | ||
41 | + private static final String REDIS_MENU_TREE_KEY = "dili_redis_MANAGE_MENU_"; | ||
42 | + | ||
43 | + | ||
44 | + /** | ||
45 | + * 过期时间 | ||
46 | + */ | ||
47 | + private static final int OVERDUE_TIME = 1 * 60 * 60 * 1000; | ||
48 | + | ||
49 | + @Autowired | ||
50 | + private MenuDao menuDao; | ||
51 | + | ||
52 | + @Autowired | ||
53 | + private NavbarManager navbarManager; | ||
54 | + | ||
55 | + @Autowired | ||
56 | + private ResourceManager resourceManager; | ||
57 | + | ||
58 | + @Autowired | ||
59 | + private RoleManager roleManager; | ||
60 | + | ||
61 | + @Autowired | ||
62 | + private RedisUtil redisUtils; | ||
63 | + | ||
64 | + | ||
65 | + | ||
66 | + public PageTemplate find(BaseQuery bq) { | ||
67 | + List<Menu> list = menuDao.listByCondition(bq); | ||
68 | + int totalSize = menuDao.countByCondition(bq); | ||
69 | + return PageTemplate.create(bq, totalSize, list); | ||
70 | + } | ||
71 | + | ||
72 | + public Integer count(BaseQuery bq){ | ||
73 | + int totalSize = menuDao.countByCondition(bq); | ||
74 | + return totalSize; | ||
75 | + } | ||
76 | + | ||
77 | + @Override | ||
78 | + public List<Menu> fetchAllTree() { | ||
79 | + String key = Menu.allTreeKey(); | ||
80 | +// if (redisUtils.checkKeyExists(key)) { | ||
81 | +// List<Menu> menus = redisUtils.getObject(key, new ArrayList<Menu>().getClass()); | ||
82 | +// return menus; | ||
83 | +// } | ||
84 | + List<Menu> menus = menuDao.findAll(); | ||
85 | + Set<Menu> menuSet = new HashSet<>(menus); | ||
86 | + List<Menu> menuTree = parseTree(menuSet); | ||
87 | +// redisUtils.setObject(key, menuTree); | ||
88 | + return menuTree; | ||
89 | + } | ||
90 | + | ||
91 | + /** | ||
92 | + * 根据用户ID获取菜单 | ||
93 | + * @param id | ||
94 | + * @return | ||
95 | + */ | ||
96 | + public List<Menu> findByUserId(Long id) { | ||
97 | +// String key = REDIS_MENU_TREE_KEY + id.toString(); | ||
98 | +// if (redisUtils.checkKeyExists(key)) { | ||
99 | +// List<Menu> menus = redisUtils.getObject(key, new ArrayList<Menu>().getClass()); | ||
100 | +// return menus; | ||
101 | +// } | ||
102 | + List<Menu> menus = menuDao.findByUserId(id); | ||
103 | + Set<Menu> menuSet = new HashSet<>(menus); | ||
104 | + List<Menu> menuTree = parseTree(menuSet); | ||
105 | +// redisUtils.setObjectByExpire(key, menuTree, OVERDUE_TIME); | ||
106 | + return menuTree; | ||
107 | + } | ||
108 | + | ||
109 | + @Override | ||
110 | + public List<Menu> findByRole(Long id) { | ||
111 | + return menuDao.findByRole(id); | ||
112 | + } | ||
113 | + | ||
114 | + /** | ||
115 | + * 转换成树 | ||
116 | + * @param menus | ||
117 | + * @return | ||
118 | + */ | ||
119 | + private List<Menu> parseTree(Set<Menu> menus) { | ||
120 | + List<Menu> temp = parseMenu(menus); | ||
121 | + // menus.addAll(temp); | ||
122 | + // Map<Long, Menu> tree = parseNav(menus); | ||
123 | + List<Menu> list = new ArrayList<>(); | ||
124 | +// for (Menu m : tree.values()) { | ||
125 | +// m.sortChildren(); | ||
126 | +// list.add(m); | ||
127 | +// } | ||
128 | + for (Menu m : temp) { | ||
129 | + m.sortChildren(); | ||
130 | + list.add(m); | ||
131 | + } | ||
132 | + return list; | ||
133 | + } | ||
134 | + | ||
135 | + /** | ||
136 | + * 转换菜单的层次结构 | ||
137 | + * 注: 会修改menus里面的对象 | ||
138 | + * @param menus | ||
139 | + * @return 在权限列表中没有的上层权限 | ||
140 | + */ | ||
141 | + private List<Menu> parseMenu(Set<Menu> menus){ | ||
142 | +// List<Menu> list = menuDao.findByParent(0l); | ||
143 | + Menu root = menuDao.getById(0l); | ||
144 | + | ||
145 | + List<Menu> rootMenus = getMenusWithParentId(root.getId(), menus); | ||
146 | + //Menu root = new Menu(-1l); | ||
147 | +// Menu root = list.get(0); | ||
148 | + Menu rootmenu = buildMenuTree(root , rootMenus, menus); | ||
149 | + // List<Menu> temp = new ArrayList<>(); | ||
150 | + // Map<Long, Menu> menuMap = Maps.newHashMap(); | ||
151 | + // for (Menu menu : menus) { | ||
152 | + // menuMap.put(menu.getId(), menu); | ||
153 | + // } | ||
154 | + // for (Menu menu : menus) { | ||
155 | + // List<Menu> t = regroup(menu, menuMap); | ||
156 | + // temp.addAll(t); | ||
157 | + // } | ||
158 | + rootmenu.sortChildren(); | ||
159 | + return rootmenu.getChildren(); | ||
160 | + } | ||
161 | + | ||
162 | + private List<Menu> getMenusWithParentId(Long parentId, Set<Menu> menus) { | ||
163 | + List<Menu> children = new ArrayList<Menu>(); | ||
164 | + for (Menu menu : menus) | ||
165 | + if (menu.getParentId().equals(parentId)) | ||
166 | + children.add(menu); | ||
167 | + return children; | ||
168 | + | ||
169 | + } | ||
170 | + | ||
171 | + private Menu buildMenuTree(Menu parent, List<Menu> children, Set<Menu> nodes) { | ||
172 | + for(Menu node : children) { | ||
173 | + buildMenuTree(node, getMenusWithParentId(node.getId(), nodes), nodes); | ||
174 | + } | ||
175 | + parent.getChildren().addAll(children); | ||
176 | + return parent; | ||
177 | + } | ||
178 | + | ||
179 | + | ||
180 | + /** | ||
181 | + * 重组层次结构 | ||
182 | + * @param menu | ||
183 | + * @param menuMap | ||
184 | + * @return | ||
185 | + */ | ||
186 | + private List<Menu> regroup(Menu menu, Map<Long, Menu> menuMap) { | ||
187 | + | ||
188 | + List<Menu> temp = new ArrayList<>(); | ||
189 | + //如果在map中找到以某menu的父节点作为id的menu,则说明该节点不是父节点 | ||
190 | + Menu parent = menuMap.get(menu.getParentId()); | ||
191 | + //parent为空说明该节点为顶级父节点,则直接返回该对象 | ||
192 | + if (parent == null) { | ||
193 | + //menuMap.put(menu.getParentId(), parent); | ||
194 | + temp.add(menu); | ||
195 | + // List<Menu> t = regroup(parent, menuMap); | ||
196 | + // temp.addAll(t); | ||
197 | + } else { | ||
198 | + //如果parent不为空,说明该对象有父级,则将该对象加入其父对象的子集中,并返回,并迭代该对象看是否还有父级 | ||
199 | + parent.addChildren(menu); | ||
200 | + } | ||
201 | + return temp; | ||
202 | + } | ||
203 | +// private List<Menu> regroup(Menu menu, Map<Long, Menu> menuMap) { | ||
204 | +// List<Menu> temp = new ArrayList<>(); | ||
205 | +// if (menu.getIsRoot() != 0) { | ||
206 | +// return temp; | ||
207 | +// } | ||
208 | +// Menu parent = menuMap.get(menu.getParentId()); | ||
209 | +// if (parent == null) { | ||
210 | +// Menu par = findOne(menu.getParentId()); | ||
211 | +// if (par != null) { | ||
212 | +// parent = par; | ||
213 | +// menuMap.put(menu.getParentId(), parent); | ||
214 | +// temp.add(parent); | ||
215 | +// List<Menu> t = regroup(parent, menuMap); | ||
216 | +// temp.addAll(t); | ||
217 | +// } | ||
218 | +// } | ||
219 | +// parent.addChildren(menu); | ||
220 | +// return temp; | ||
221 | +// } | ||
222 | + | ||
223 | + /** | ||
224 | + * 将nav转换成menu, 并转换成一个树结构 | ||
225 | + * @param menus | ||
226 | + * @return | ||
227 | + */ | ||
228 | +// private Map<Long, Menu> parseNav(Set<Menu> menus){ | ||
229 | +// Map<Long, Menu> tree = new HashMap<>(); | ||
230 | +// for (Menu menu : menus) { | ||
231 | +// if(menu.getIsRoot() == 0){ | ||
232 | +// continue; | ||
233 | +// } | ||
234 | +// if (!tree.containsKey(menu.getNavbarId())) { | ||
235 | +// Menu nav = new Menu(); | ||
236 | +// Navbar navbar = navbarManager.findOne(menu.getNavbarId()); | ||
237 | +// nav.setLabel(navbar.getProjectName()); | ||
238 | +// nav.setId(menu.getNavbarId()); | ||
239 | +// nav.setParentId(0l); | ||
240 | +// nav.setType(2); | ||
241 | +// tree.put(menu.getNavbarId(), nav); | ||
242 | +// } | ||
243 | +// Menu nav = tree.get(menu.getNavbarId()); | ||
244 | +// nav.addChildren(menu); | ||
245 | +// } | ||
246 | +// return tree; | ||
247 | +// } | ||
248 | + | ||
249 | + | ||
250 | + /** | ||
251 | + * 根据父节点查询菜单 | ||
252 | + * @param id | ||
253 | + * @return | ||
254 | + */ | ||
255 | + public List<Menu> findByParent(Long id) { | ||
256 | + if (redisUtils.checkKeyExists(Menu.listChildrenKey(id))) { | ||
257 | + return redisUtils.getList(Menu.listChildrenKey(id), Menu.class); | ||
258 | + } | ||
259 | + List<Menu> list = menuDao.findByParent(id); | ||
260 | + redisUtils.setObject(Menu.listChildrenKey(id), list); | ||
261 | + return list; | ||
262 | + } | ||
263 | + | ||
264 | + | ||
265 | + @Override | ||
266 | + public void sort(Menu menu) { | ||
267 | + if(LOG.isInfoEnabled()) { | ||
268 | + LOG.info("开始进行移动位置, menu:" + JSON.toJSONString(menu)); | ||
269 | + } | ||
270 | + // 1. 旧node | ||
271 | + Menu obj = findOne(menu.getId()); | ||
272 | + // 2. 旧list | ||
273 | + List<Menu> list = findByParent(obj.getParentId()); | ||
274 | + // 3. 剔除旧node,添加新状态(TODO,可以优化为交换) | ||
275 | + Menu t = null; | ||
276 | + for (int i = 0; i < list.size(); i ++) { | ||
277 | + Menu m = list.get(i); | ||
278 | + if (m.getId().equals(obj.getId())) { | ||
279 | + t = m; | ||
280 | + break; | ||
281 | + } | ||
282 | + } | ||
283 | + list.remove(t); | ||
284 | + int sort = menu.getSort(); | ||
285 | + if (sort >= list.size()) { | ||
286 | + sort = list.size(); | ||
287 | + } | ||
288 | + if (sort < 0) { | ||
289 | + sort = 0; | ||
290 | + } | ||
291 | + list.add(sort, t); | ||
292 | + // 4. 新list | ||
293 | + for (int i = 0; i < list.size(); i ++) { | ||
294 | + Menu m = list.get(i); | ||
295 | + m.setSort(i); | ||
296 | + update(m); | ||
297 | + } | ||
298 | + if (LOG.isInfoEnabled()) { | ||
299 | + LOG.info("移动位置成功!"); | ||
300 | + } | ||
301 | + } | ||
302 | + | ||
303 | + @Override | ||
304 | + public void move(Menu menu) { | ||
305 | + Menu m = menuDao.getById(menu.getId()); | ||
306 | + m.setParentId(menu.getParentId()); | ||
307 | + menuDao.update(m); | ||
308 | + m.setSort(0); | ||
309 | + sort(m); | ||
310 | + } | ||
311 | + | ||
312 | + | ||
313 | + public Menu findOne(Long pk) { | ||
314 | + if (redisUtils.checkKeyExists(Menu.itemKey(pk))) { | ||
315 | + return redisUtils.getObject(Menu.itemKey(pk), Menu.class); | ||
316 | + } | ||
317 | + Menu menu = menuDao.getById(pk); | ||
318 | + redisUtils.setObject(Menu.itemKey(pk), menu); | ||
319 | + return menu; | ||
320 | + } | ||
321 | + | ||
322 | + public Boolean save(Menu menu) { | ||
323 | + // 去重 | ||
324 | + BaseQuery bq = new BaseQuery(); | ||
325 | + bq.addParam("parentId", menu.getParentId().toString()); | ||
326 | + bq.addParam("label", menu.getLabel().toString()); | ||
327 | + if (menuDao.countByCondition(bq) > 0) { | ||
328 | + return false; | ||
329 | + } | ||
330 | + | ||
331 | + if (menu.getParentId() != null) { | ||
332 | + redisUtils.deleteByKey(Menu.listChildrenKey(menu.getParentId())); | ||
333 | + } | ||
334 | + redisUtils.deleteByKey(Menu.allTreeKey()); | ||
335 | +// if(menu.getType().equals(Menu.TYPE_LEAF)) { | ||
336 | +// Resource resource = Resource.makeGetResource(menu); | ||
337 | +// resourceManager.save(resource); | ||
338 | +// } | ||
339 | + | ||
340 | + return menuDao.save(menu); | ||
341 | + } | ||
342 | + | ||
343 | + public Boolean update(Menu menu) { | ||
344 | +// // 去重 | ||
345 | +// BaseQuery bq = new BaseQuery(); | ||
346 | +// bq.addParam("parentId", menu.getParentId().toString()); | ||
347 | +// bq.addParam("label", menu.getLabel().toString()); | ||
348 | +// List<Menu> r = menuDao.listByCondition(bq); | ||
349 | +// if (r.size() == 1 && menu.getId() != r.get(0).getId()) { | ||
350 | +// return false; | ||
351 | +// } | ||
352 | + | ||
353 | + if (menu.getParentId() != null) { | ||
354 | + redisUtils.deleteByKey(Menu.listChildrenKey(menu.getParentId())); | ||
355 | + } | ||
356 | + redisUtils.deleteByKey(Menu.itemKey(menu.getId())); | ||
357 | + redisUtils.deleteByKey(Menu.allTreeKey()); | ||
358 | + return menuDao.update(menu); | ||
359 | + } | ||
360 | + | ||
361 | + public Boolean delByNavbar(Long id) { | ||
362 | + return menuDao.delByNavbar(id); | ||
363 | + } | ||
364 | + | ||
365 | + public Boolean del(Long id) { | ||
366 | + Menu menu = findOne(id); | ||
367 | + if (menu == null) { | ||
368 | + return true; | ||
369 | + } | ||
370 | + recursionMenuUsed(menu); | ||
371 | + | ||
372 | + if (menu.getParentId() != null) { | ||
373 | + redisUtils.deleteByKey(Menu.listChildrenKey(menu.getParentId())); | ||
374 | + } | ||
375 | + redisUtils.deleteByKey(Menu.itemKey(id)); | ||
376 | + redisUtils.deleteByKey(Menu.allTreeKey()); | ||
377 | + | ||
378 | + recursionDel(menu); | ||
379 | + | ||
380 | + return true; | ||
381 | + } | ||
382 | + | ||
383 | + /** | ||
384 | + * 递归删除菜单 | ||
385 | + * @param menu | ||
386 | + */ | ||
387 | + private void recursionDel(Menu menu){ | ||
388 | + if(menu.getType().equals(Menu.TYPE_DIR)) { | ||
389 | + List<Menu> list = menuDao.findByParent(menu.getId()); | ||
390 | + for (Menu m : list) { | ||
391 | + recursionDel(m); | ||
392 | + } | ||
393 | + } | ||
394 | + List<Resource> resources = resourceManager.findByParent(menu.getId()); | ||
395 | + for (Resource r : resources) { | ||
396 | + resourceManager.del(r.getId()); | ||
397 | + } | ||
398 | + menuDao.deleteById(menu.getId()); | ||
399 | + } | ||
400 | + | ||
401 | + /** | ||
402 | + * 递归判断菜单是否被使用 | ||
403 | + * @param menu | ||
404 | + */ | ||
405 | + private void recursionMenuUsed(Menu menu) { | ||
406 | + if (menu == null || menu.getId() == null) { | ||
407 | + return ; | ||
408 | + } | ||
409 | + String using = isUsed(menu.getId()); | ||
410 | + if (!using.equals("")) { | ||
411 | + throw new RuntimeException("菜单或子菜单在角色[" +using +"]中正在使用, 不能进行删除!"); | ||
412 | + } | ||
413 | + if (menu.getType().equals(Menu.TYPE_DIR)) { | ||
414 | + List<Menu> list = menuDao.findByParent(menu.getId()); | ||
415 | + for (Menu m : list) { | ||
416 | + recursionMenuUsed(m); | ||
417 | + } | ||
418 | + } | ||
419 | + } | ||
420 | + | ||
421 | + /** | ||
422 | + * 是否被使用 | ||
423 | + * @param menuId | ||
424 | + * @return | ||
425 | + */ | ||
426 | + private String isUsed(Long menuId) { | ||
427 | + List<Role> list = roleManager.findByMenu(menuId); | ||
428 | + String roles = ""; | ||
429 | + for (Role r : list) { | ||
430 | + if (!"".equals(roles)) { | ||
431 | + roles += ","; | ||
432 | + } | ||
433 | + roles += r.getRoleName(); | ||
434 | + } | ||
435 | + return roles; | ||
436 | + } | ||
437 | + | ||
438 | + @Override | ||
439 | + public List<MenuJson> findAllMenuJson() { | ||
440 | + // TODO Auto-generated method stub | ||
441 | + return menuDao.findAllMenuJson(); | ||
442 | + } | ||
443 | + | ||
444 | + @Override | ||
445 | + public Integer countAllChild(Long parentId) { | ||
446 | + return menuDao.countAllChild(parentId); | ||
447 | + } | ||
448 | + | ||
449 | + @Override | ||
450 | + public List<Menu> findAll() { | ||
451 | + return menuDao.findAll(); | ||
452 | + } | ||
453 | + | ||
454 | + | ||
455 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/navbar/NavbarManager.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/navbar/NavbarManager.java | ||
1 | +package com.diligrp.manage.manager.navbar; | ||
2 | + | ||
3 | +import com.diligrp.manage.domain.Navbar; | ||
4 | +import com.diligrp.website.util.dao.BaseQuery; | ||
5 | +import com.diligrp.website.util.web.PageTemplate; | ||
6 | + | ||
7 | +import java.util.List; | ||
8 | + | ||
9 | +/** | ||
10 | + * <B>Description</B> <br /> | ||
11 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
12 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
13 | + * <B>Company</B> 地利集团 | ||
14 | + * @createTime 2014-7-3 14:24:40 | ||
15 | + * @author template | ||
16 | + */ | ||
17 | +public interface NavbarManager { | ||
18 | + | ||
19 | + public PageTemplate find(BaseQuery bq); | ||
20 | + | ||
21 | + public Navbar findOne(Long pk); | ||
22 | + | ||
23 | + public Boolean save(Navbar navbar); | ||
24 | + | ||
25 | + public Boolean update(Navbar navbar); | ||
26 | + | ||
27 | + public Boolean del(Long id); | ||
28 | + | ||
29 | + public List<Navbar> findAll(BaseQuery bq); | ||
30 | + | ||
31 | + /** | ||
32 | + * 根据名称查询 | ||
33 | + * @param name | ||
34 | + * @return | ||
35 | + */ | ||
36 | + public Navbar findByCode(String name); | ||
37 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/navbar/impl/NavbarManagerImpl.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/navbar/impl/NavbarManagerImpl.java | ||
1 | +package com.diligrp.manage.manager.navbar.impl; | ||
2 | + | ||
3 | +import java.util.List; | ||
4 | + | ||
5 | +import org.slf4j.Logger; | ||
6 | +import org.slf4j.LoggerFactory; | ||
7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
8 | +import org.springframework.stereotype.Component; | ||
9 | + | ||
10 | +import com.diligrp.manage.dao.MenuDao; | ||
11 | +import com.diligrp.manage.dao.NavbarDao; | ||
12 | +import com.diligrp.manage.domain.Navbar; | ||
13 | +import com.diligrp.manage.manager.navbar.NavbarManager; | ||
14 | +import com.diligrp.website.util.dao.BaseQuery; | ||
15 | +import com.diligrp.website.util.web.PageTemplate; | ||
16 | + | ||
17 | +/** | ||
18 | + * <B>Description</B> <br /> | ||
19 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
20 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
21 | + * <B>Company</B> 地利集团 | ||
22 | + * @createTime 2014-7-3 14:24:40 | ||
23 | + * @author template | ||
24 | + */ | ||
25 | +@Component | ||
26 | +public class NavbarManagerImpl implements NavbarManager { | ||
27 | + private final static Logger LOG = LoggerFactory | ||
28 | + .getLogger(NavbarManagerImpl.class); | ||
29 | + | ||
30 | + @Autowired | ||
31 | + private NavbarDao navbarDao; | ||
32 | + | ||
33 | + @Autowired | ||
34 | + private MenuDao menuDao; | ||
35 | + | ||
36 | + public PageTemplate find(BaseQuery bq) { | ||
37 | + List<Navbar> list = navbarDao.listByCondition(bq); | ||
38 | + int totalSize = navbarDao.countByCondition(bq); | ||
39 | + return PageTemplate.create(bq, totalSize, list); | ||
40 | + } | ||
41 | + | ||
42 | + public Navbar findOne(Long pk) { | ||
43 | + return navbarDao.getById(pk); | ||
44 | + } | ||
45 | + | ||
46 | + public Boolean save(Navbar navbar) { | ||
47 | + return navbarDao.save(navbar); | ||
48 | + } | ||
49 | + | ||
50 | + public Boolean update(Navbar navbar) { | ||
51 | + return navbarDao.update(navbar); | ||
52 | + } | ||
53 | + | ||
54 | + public Boolean del(Long id) { | ||
55 | + menuDao.delByNavbar(id); | ||
56 | + return navbarDao.deleteById(id); | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public List<Navbar> findAll(BaseQuery bq) { | ||
61 | + return navbarDao.findAll(bq); | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
65 | + * 根据名称查询 | ||
66 | + * @param name | ||
67 | + * @return | ||
68 | + */ | ||
69 | + public Navbar findByCode(String name) { | ||
70 | + return navbarDao.findByCode(name); | ||
71 | + } | ||
72 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/resource/ResourceManager.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/resource/ResourceManager.java | ||
1 | +package com.diligrp.manage.manager.resource; | ||
2 | + | ||
3 | +import java.util.List; | ||
4 | + | ||
5 | +import com.diligrp.manage.domain.Resource; | ||
6 | +import com.diligrp.website.util.dao.BaseQuery; | ||
7 | +import com.diligrp.website.util.web.PageTemplate; | ||
8 | + | ||
9 | +/** | ||
10 | + * <B>Description</B> <br /> | ||
11 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
12 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
13 | + * <B>Company</B> 地利集团 | ||
14 | + * @createTime 2014-7-3 14:24:40 | ||
15 | + * @author template | ||
16 | + */ | ||
17 | +public interface ResourceManager { | ||
18 | + | ||
19 | + public PageTemplate find(BaseQuery bq); | ||
20 | + | ||
21 | + public Resource findOne(Long pk); | ||
22 | + | ||
23 | + public Boolean save(Resource resource); | ||
24 | + | ||
25 | + public Boolean update(Resource resource); | ||
26 | + | ||
27 | + public Boolean del(Long id); | ||
28 | + | ||
29 | + public List<Resource> listAllResourceJson(Resource resource); | ||
30 | + | ||
31 | + public List<String> loadResourceListToCache(); | ||
32 | + | ||
33 | + public List<Resource> findByRole(Long id); | ||
34 | + | ||
35 | + public List<Resource> findAllOpen(); | ||
36 | + | ||
37 | + public List<Resource> findAll(); | ||
38 | + | ||
39 | +// public Boolean removeRoleAssociation(Long id); | ||
40 | + | ||
41 | + public boolean checkResourceUrlUnique(String url, Long id); | ||
42 | + | ||
43 | + public boolean checkResourceNameUnique(String resourceName, Long id); | ||
44 | + | ||
45 | + public List<Resource> findByParent(Long id); | ||
46 | +// public void deleteByNavbarId(Long id); | ||
47 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/resource/impl/ResourceManagerImpl.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/resource/impl/ResourceManagerImpl.java | ||
1 | +package com.diligrp.manage.manager.resource.impl; | ||
2 | + | ||
3 | +import com.diligrp.manage.dao.ResourceDao; | ||
4 | +import com.diligrp.manage.dao.ResourceUrlDao; | ||
5 | +import com.diligrp.manage.domain.Resource; | ||
6 | +import com.diligrp.manage.domain.Role; | ||
7 | +import com.diligrp.manage.manager.customRedis.RedisManager; | ||
8 | +import com.diligrp.manage.manager.resource.ResourceManager; | ||
9 | +import com.diligrp.manage.manager.role.RoleManager; | ||
10 | +import com.diligrp.manage.sdk.session.SessionConstants; | ||
11 | +import com.diligrp.website.util.dao.BaseQuery; | ||
12 | +import com.diligrp.website.util.redis.RedisUtil; | ||
13 | +import com.diligrp.website.util.web.PageTemplate; | ||
14 | +import org.slf4j.Logger; | ||
15 | +import org.slf4j.LoggerFactory; | ||
16 | +import org.springframework.beans.factory.annotation.Autowired; | ||
17 | +import org.springframework.cache.annotation.CachePut; | ||
18 | +import org.springframework.stereotype.Component; | ||
19 | +import org.springframework.transaction.annotation.Propagation; | ||
20 | +import org.springframework.transaction.annotation.Transactional; | ||
21 | + | ||
22 | +import java.util.List; | ||
23 | + | ||
24 | +/** | ||
25 | + * <B>Description</B> <br /> | ||
26 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
27 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
28 | + * <B>Company</B> 地利集团 | ||
29 | + * @createTime 2014-7-3 14:24:40 | ||
30 | + * @author template | ||
31 | + */ | ||
32 | +@Component | ||
33 | +public class ResourceManagerImpl implements ResourceManager { | ||
34 | + private final static Logger LOG = LoggerFactory | ||
35 | + .getLogger(ResourceManagerImpl.class); | ||
36 | + | ||
37 | + @Autowired | ||
38 | + private ResourceDao resourceDao; | ||
39 | + | ||
40 | + @Autowired | ||
41 | + private ResourceUrlDao resourceUrlDao; | ||
42 | + | ||
43 | + @Autowired | ||
44 | + private RedisUtil manageRedisUtil; | ||
45 | + | ||
46 | + @Autowired | ||
47 | + private RoleManager roleManager; | ||
48 | + | ||
49 | + public RedisManager getRedisManager() { | ||
50 | + return redisManager; | ||
51 | + } | ||
52 | + | ||
53 | + @Autowired | ||
54 | + private RedisManager redisManager; | ||
55 | + | ||
56 | + public PageTemplate find(BaseQuery bq) { | ||
57 | + List<Resource> list = resourceDao.listByCondition(bq); | ||
58 | + int totalSize = resourceDao.countByCondition(bq); | ||
59 | + return PageTemplate.create(bq, totalSize, list); | ||
60 | + } | ||
61 | + | ||
62 | +// @Override | ||
63 | +// public void afterPropertiesSet() throws Exception { | ||
64 | +// loadResourceListToCache(); | ||
65 | +// } | ||
66 | + | ||
67 | + @Override | ||
68 | + public List<String> loadResourceListToCache() { | ||
69 | + LOG.info("---Load Resource List---"); | ||
70 | + List<String> list = resourceDao.listAllUrls(); | ||
71 | + manageRedisUtil.setObject(SessionConstants.CACHED_RESOURCE_LIST_KEY, list); | ||
72 | + LOG.info(String.format("Resource List Records: %d", list.size())); | ||
73 | + LOG.info("---Load Resource List Successfully---"); | ||
74 | + return list; | ||
75 | + } | ||
76 | + | ||
77 | +// @Cacheable(value = "rc", key = "'manage:res:resId' + #pk") | ||
78 | + public Resource findOne(Long pk) { | ||
79 | + return resourceDao.getById(pk); | ||
80 | + } | ||
81 | + | ||
82 | + @Transactional(propagation=Propagation.REQUIRED) | ||
83 | + public Boolean save(Resource resource) { | ||
84 | + // 去重 | ||
85 | +// BaseQuery bq = new BaseQuery(); | ||
86 | +// bq.addParam("resourceName", resource.getResourceName()); | ||
87 | +// if (resourceDao.countByCondition(bq) > 0) { | ||
88 | +// return false; | ||
89 | +// } | ||
90 | + | ||
91 | + Boolean b = resourceDao.save(resource); | ||
92 | + // TODO 整理一下代码,有些代码要删除了 | ||
93 | + manageRedisUtil.deleteByKey(SessionConstants.CACHED_RESOURCE_LIST_KEY); | ||
94 | + return b; | ||
95 | + } | ||
96 | + | ||
97 | + @Transactional(propagation=Propagation.REQUIRED) | ||
98 | +// @CacheEvict(value = "rc", key = "'manage:res:resId:' + #resource.getId()") | ||
99 | + public Boolean update(Resource resource) { | ||
100 | + // 去重 | ||
101 | +// BaseQuery bq = new BaseQuery(); | ||
102 | +// bq.addParam("resourceName", resource.getResourceName()); | ||
103 | +// List<Resource> r = resourceDao.listByCondition(bq); | ||
104 | +// if (r.size() == 1 && resource.getId() != r.get(0).getId()) { | ||
105 | +// return false; | ||
106 | +// } | ||
107 | + | ||
108 | + Boolean b = resourceDao.update(resource); | ||
109 | + // TODO 整理一下代码,有些代码要删除了 | ||
110 | + manageRedisUtil.deleteByKey(SessionConstants.CACHED_RESOURCE_LIST_KEY); | ||
111 | + return b; | ||
112 | + } | ||
113 | + | ||
114 | + @CachePut(value="rc", key="'manage:wasteResKey'", condition="#root.target.getRedisManager().delRes(#id)") | ||
115 | + public Boolean del(Long id) { | ||
116 | + Resource re = findOne(id); | ||
117 | + List<Role> roles = roleManager.findByResource(id); | ||
118 | + if (roles != null && roles.size() > 0) { | ||
119 | + StringBuffer sb = new StringBuffer(); | ||
120 | + Boolean b = false; | ||
121 | + for (Role r : roles) { | ||
122 | + if (b) { | ||
123 | + sb.append(","); | ||
124 | + } | ||
125 | + b = true; | ||
126 | + sb.append(r.getRoleName()); | ||
127 | + } | ||
128 | + throw new RuntimeException("[" + sb.toString() + "]引用了权限["+re.getResourceName()+"]!无法删除!"); | ||
129 | + } | ||
130 | + | ||
131 | + Boolean b = resourceDao.deleteById(id); | ||
132 | + resourceUrlDao.deleteByParentId(id); | ||
133 | + // TODO 整理一下代码,有些代码要删除了 | ||
134 | + manageRedisUtil.deleteByKey(SessionConstants.CACHED_RESOURCE_LIST_KEY); | ||
135 | + return b; | ||
136 | + } | ||
137 | + | ||
138 | + @Override | ||
139 | +// @Cacheable(value = "rc", key = "'manage:resJsonAll'") | ||
140 | + public List<Resource> listAllResourceJson(Resource resource) { | ||
141 | + return resourceDao.listAllResourceJson(resource); | ||
142 | + } | ||
143 | + | ||
144 | + @Override | ||
145 | +// @Cacheable(value = "rc", key = "'manage:roleResAll:roleId' + #id") | ||
146 | + public List<Resource> findByRole(Long id) { | ||
147 | + return resourceDao.findByRole(id); | ||
148 | + } | ||
149 | + | ||
150 | + public List<Resource> findByParent(Long id) { | ||
151 | + return resourceDao.findByParent(id); | ||
152 | + } | ||
153 | + | ||
154 | + @Override | ||
155 | +// @Cacheable(value = "rc", key = "'manage:resAllOpen'") | ||
156 | + public List<Resource> findAllOpen() { | ||
157 | + return resourceDao.findAll(1); | ||
158 | + } | ||
159 | + | ||
160 | +// @Cacheable(value = "rc", key = "'manage:resAll'") | ||
161 | + public List<Resource> findAll() { | ||
162 | + return resourceDao.findAll(null); | ||
163 | + } | ||
164 | + | ||
165 | + // 沒有地方使用,未添加缓存 | ||
166 | +// @Override | ||
167 | +// public Boolean removeRoleAssociation(Long id) { | ||
168 | +// return resourceDao.removeRoleAssociation(id); | ||
169 | +// } | ||
170 | + | ||
171 | + @Override | ||
172 | + public boolean checkResourceUrlUnique(String url, Long id) { | ||
173 | + return resourceDao.checkResourceUrlUnique(url, id); | ||
174 | + } | ||
175 | + | ||
176 | + @Override | ||
177 | + public boolean checkResourceNameUnique(String resourceName, Long id) { | ||
178 | + return resourceDao.checkResourceNameUnique(resourceName, id); | ||
179 | + } | ||
180 | + | ||
181 | +// @Override | ||
182 | +// public void deleteByNavbarId(Long id) { | ||
183 | +// resourceDao.deleteByNavbarId(id); | ||
184 | +// } | ||
185 | + | ||
186 | +} |
diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/resourceurl/resource/ResourceUrlManager.java
0 → 100644
1 | +++ a/diligrp-manage-manager/src/main/java/com/diligrp/manage/manager/resourceurl/resource/ResourceUrlManager.java | ||
1 | +package com.diligrp.manage.manager.resourceurl.resource; | ||
2 | + | ||
3 | +import com.diligrp.manage.domain.ResourceUrl; | ||
4 | +import com.diligrp.website.util.dao.BaseQuery; | ||
5 | + | ||
6 | +import java.util.List; | ||
7 | + | ||
8 | +/** | ||
9 | + * <B>Description</B> <br /> | ||
10 | + * <B>Copyright</B> Copyright (c) 2014 www.dili7 All rights reserved. <br /> | ||
11 | + * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> | ||
12 | + * <B>Company</B> 地利集团 | ||
13 | + * @createTime 2014-7-3 14:24:40 | ||
14 | + * @author template | ||
15 | + */ | ||
16 | +public interface ResourceUrlManager { | ||
17 | + | ||
18 | +// public PageTemplate find(BaseQuery bq); | ||
19 | + | ||
20 | +// public Resource findOne(Long pk); | ||
21 | + | ||
22 | +// public Boolean del(Long id); | ||
23 | + | ||
24 | +// public List<Resource> findAll(); | ||
25 | + | ||
26 | + public Boolean saveOrUpdate(Long parentId, List<ResourceUrl> urls); | ||
27 | + | ||
28 | + public List<ResourceUrl> listByCondition(BaseQuery bq); | ||
29 | +} |