Commit 10b04f384f1a0ee854a88fb5a4c5aaf9da67080f
1 parent
664d8476a1
Exists in
master
and in
1 other branch
platform permission
Showing 8 changed files with 355 additions and 34 deletions
- platform-biz-service/src/main/java/com/lyms/platform/permission/dao/RegionsMapper.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/model/Permissions.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/model/Regions.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/model/RegionsQuery.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/RegionsService.java
- platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/RegionsServiceImpl.java
- platform-biz-service/src/main/resources/mainOrm/Regions.xml
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RegionController.java
platform-biz-service/src/main/java/com/lyms/platform/permission/dao/RegionsMapper.java
View file @
10b04f3
1 | +package com.lyms.platform.permission.dao; | |
2 | + | |
3 | + | |
4 | + | |
5 | +import com.lyms.platform.permission.model.Regions; | |
6 | +import com.lyms.platform.permission.model.RegionsQuery; | |
7 | + | |
8 | +import java.util.List; | |
9 | + | |
10 | +public interface RegionsMapper {public void addRegions(Regions obj);public void updateRegions(Regions obj);public void deleteRegions(Integer id);public Regions getRegions(Integer id);public int queryRegionsCount(RegionsQuery query);public List<Regions> queryRegions(RegionsQuery query); | |
11 | + | |
12 | +} |
platform-biz-service/src/main/java/com/lyms/platform/permission/model/Permissions.java
View file @
10b04f3
... | ... | @@ -2,177 +2,177 @@ |
2 | 2 | |
3 | 3 | import java.util.Date; |
4 | 4 | |
5 | -public class Permissions {private Integer id;private Integer type;private String moduleName;private String moduleCode;private String functionName;private String functionCode;private String permissionName;private String action;private String ext;private String url;private Integer publishId;private String publishName;private Integer yn;private Date modified;private Date created;private Integer ismenu; | |
5 | +public class Permissions { | |
6 | + private Integer id; | |
7 | + private Integer type; | |
8 | + private String moduleName; | |
9 | + private String moduleCode; | |
10 | + private String functionName; | |
11 | + private String functionCode; | |
12 | + private String permissionName; | |
13 | + private String action; | |
14 | + private String ext; | |
15 | + private String url; | |
16 | + private Integer publishId; | |
17 | + private String publishName; | |
18 | + private Integer yn; | |
19 | + private Date modified; | |
20 | + private Date created; | |
21 | + private Integer ismenu; | |
6 | 22 | |
7 | -public Integer getId() { | |
23 | + public Integer getId() { | |
8 | 24 | return id; |
9 | 25 | } |
10 | 26 | |
11 | 27 | |
12 | - | |
13 | 28 | public void setId(Integer id) { |
14 | 29 | this.id = id; |
15 | 30 | |
16 | 31 | } |
17 | 32 | |
18 | -public Integer getType() { | |
33 | + public Integer getType() { | |
19 | 34 | return type; |
20 | 35 | } |
21 | 36 | |
22 | 37 | |
23 | - | |
24 | 38 | public void setType(Integer type) { |
25 | 39 | this.type = type; |
26 | 40 | |
27 | 41 | } |
28 | 42 | |
29 | -public String getModuleName() { | |
43 | + public String getModuleName() { | |
30 | 44 | return moduleName; |
31 | 45 | } |
32 | 46 | |
33 | 47 | |
34 | - | |
35 | 48 | public void setModuleName(String moduleName) { |
36 | 49 | this.moduleName = moduleName; |
37 | 50 | |
38 | 51 | } |
39 | 52 | |
40 | -public String getModuleCode() { | |
53 | + public String getModuleCode() { | |
41 | 54 | return moduleCode; |
42 | 55 | } |
43 | 56 | |
44 | 57 | |
45 | - | |
46 | 58 | public void setModuleCode(String moduleCode) { |
47 | 59 | this.moduleCode = moduleCode; |
48 | 60 | |
49 | 61 | } |
50 | 62 | |
51 | -public String getFunctionName() { | |
63 | + public String getFunctionName() { | |
52 | 64 | return functionName; |
53 | 65 | } |
54 | 66 | |
55 | 67 | |
56 | - | |
57 | 68 | public void setFunctionName(String functionName) { |
58 | 69 | this.functionName = functionName; |
59 | 70 | |
60 | 71 | } |
61 | 72 | |
62 | -public String getFunctionCode() { | |
73 | + public String getFunctionCode() { | |
63 | 74 | return functionCode; |
64 | 75 | } |
65 | 76 | |
66 | 77 | |
67 | - | |
68 | 78 | public void setFunctionCode(String functionCode) { |
69 | 79 | this.functionCode = functionCode; |
70 | 80 | |
71 | 81 | } |
72 | 82 | |
73 | -public String getPermissionName() { | |
83 | + public String getPermissionName() { | |
74 | 84 | return permissionName; |
75 | 85 | } |
76 | 86 | |
77 | 87 | |
78 | - | |
79 | 88 | public void setPermissionName(String permissionName) { |
80 | 89 | this.permissionName = permissionName; |
81 | 90 | |
82 | 91 | } |
83 | 92 | |
84 | -public String getAction() { | |
93 | + public String getAction() { | |
85 | 94 | return action; |
86 | 95 | } |
87 | 96 | |
88 | 97 | |
89 | - | |
90 | 98 | public void setAction(String action) { |
91 | 99 | this.action = action; |
92 | 100 | |
93 | 101 | } |
94 | 102 | |
95 | -public String getExt() { | |
103 | + public String getExt() { | |
96 | 104 | return ext; |
97 | 105 | } |
98 | 106 | |
99 | 107 | |
100 | - | |
101 | 108 | public void setExt(String ext) { |
102 | 109 | this.ext = ext; |
103 | 110 | |
104 | 111 | } |
105 | 112 | |
106 | -public String getUrl() { | |
113 | + public String getUrl() { | |
107 | 114 | return url; |
108 | 115 | } |
109 | 116 | |
110 | 117 | |
111 | - | |
112 | 118 | public void setUrl(String url) { |
113 | 119 | this.url = url; |
114 | 120 | |
115 | 121 | } |
116 | 122 | |
117 | -public Integer getPublishId() { | |
123 | + public Integer getPublishId() { | |
118 | 124 | return publishId; |
119 | 125 | } |
120 | 126 | |
121 | 127 | |
122 | - | |
123 | 128 | public void setPublishId(Integer publishId) { |
124 | 129 | this.publishId = publishId; |
125 | 130 | |
126 | 131 | } |
127 | 132 | |
128 | -public String getPublishName() { | |
133 | + public String getPublishName() { | |
129 | 134 | return publishName; |
130 | 135 | } |
131 | 136 | |
132 | 137 | |
133 | - | |
134 | 138 | public void setPublishName(String publishName) { |
135 | 139 | this.publishName = publishName; |
136 | 140 | |
137 | 141 | } |
138 | 142 | |
139 | -public Integer getYn() { | |
143 | + public Integer getYn() { | |
140 | 144 | return yn; |
141 | 145 | } |
142 | 146 | |
143 | 147 | |
144 | - | |
145 | 148 | public void setYn(Integer yn) { |
146 | 149 | this.yn = yn; |
147 | 150 | |
148 | 151 | } |
149 | 152 | |
150 | -public Date getModified() { | |
153 | + public Date getModified() { | |
151 | 154 | return modified; |
152 | 155 | } |
153 | 156 | |
154 | 157 | |
155 | - | |
156 | 158 | public void setModified(Date modified) { |
157 | 159 | this.modified = modified; |
158 | 160 | |
159 | 161 | } |
160 | 162 | |
161 | -public Date getCreated() { | |
163 | + public Date getCreated() { | |
162 | 164 | return created; |
163 | 165 | } |
164 | 166 | |
165 | 167 | |
166 | - | |
167 | 168 | public void setCreated(Date created) { |
168 | 169 | this.created = created; |
169 | 170 | |
170 | 171 | } |
171 | 172 | |
172 | -public Integer getIsmenu() { | |
173 | + public Integer getIsmenu() { | |
173 | 174 | return ismenu; |
174 | 175 | } |
175 | - | |
176 | 176 | |
177 | 177 | |
178 | 178 | public void setIsmenu(Integer ismenu) { |
platform-biz-service/src/main/java/com/lyms/platform/permission/model/Regions.java
View file @
10b04f3
1 | +package com.lyms.platform.permission.model; | |
2 | + | |
3 | +public class Regions { | |
4 | + private Integer id; | |
5 | + private Integer parentId; | |
6 | + private String regionName; | |
7 | + private Integer level; | |
8 | + | |
9 | + public Integer getId() { | |
10 | + return id; | |
11 | + } | |
12 | + | |
13 | + | |
14 | + public void setId(Integer id) { | |
15 | + this.id = id; | |
16 | + | |
17 | + } | |
18 | + | |
19 | + public Integer getParentId() { | |
20 | + return parentId; | |
21 | + } | |
22 | + | |
23 | + public void setParentId(Integer parentId) { | |
24 | + this.parentId = parentId; | |
25 | + } | |
26 | + | |
27 | + public String getRegionName() { | |
28 | + return regionName; | |
29 | + } | |
30 | + | |
31 | + | |
32 | + public void setRegionName(String regionName) { | |
33 | + this.regionName = regionName; | |
34 | + | |
35 | + } | |
36 | + | |
37 | + public Integer getLevel() { | |
38 | + return level; | |
39 | + } | |
40 | + | |
41 | + | |
42 | + public void setLevel(Integer level) { | |
43 | + this.level = level; | |
44 | + | |
45 | + } | |
46 | +} |
platform-biz-service/src/main/java/com/lyms/platform/permission/model/RegionsQuery.java
View file @
10b04f3
1 | +package com.lyms.platform.permission.model; | |
2 | + | |
3 | + | |
4 | +import com.lyms.platform.common.dao.BaseQuery; | |
5 | + | |
6 | +public class RegionsQuery extends BaseQuery { | |
7 | + private Integer id; | |
8 | + private Integer parentId; | |
9 | + private String regionName; | |
10 | + private Integer level; | |
11 | + | |
12 | + public Integer getId() { | |
13 | + return id; | |
14 | + } | |
15 | + | |
16 | + | |
17 | + public void setId(Integer id) { | |
18 | + this.id = id; | |
19 | + | |
20 | + } | |
21 | + | |
22 | + public Integer getParentId() { | |
23 | + return parentId; | |
24 | + } | |
25 | + | |
26 | + public void setParentId(Integer parentId) { | |
27 | + this.parentId = parentId; | |
28 | + } | |
29 | + | |
30 | + public String getRegionName() { | |
31 | + return regionName; | |
32 | + } | |
33 | + | |
34 | + | |
35 | + public void setRegionName(String regionName) { | |
36 | + this.regionName = regionName; | |
37 | + | |
38 | + } | |
39 | + | |
40 | + public Integer getLevel() { | |
41 | + return level; | |
42 | + } | |
43 | + | |
44 | + | |
45 | + public void setLevel(Integer level) { | |
46 | + this.level = level; | |
47 | + | |
48 | + } | |
49 | +} |
platform-biz-service/src/main/java/com/lyms/platform/permission/service/RegionsService.java
View file @
10b04f3
1 | +package com.lyms.platform.permission.service; | |
2 | + | |
3 | + | |
4 | + | |
5 | +import com.lyms.platform.permission.model.Regions; | |
6 | +import com.lyms.platform.permission.model.RegionsQuery; | |
7 | + | |
8 | +import java.util.List; | |
9 | + | |
10 | +public interface RegionsService { | |
11 | + public void addRegions(Regions obj); | |
12 | + | |
13 | + public void updateRegions(Regions obj); | |
14 | + | |
15 | + public void deleteRegions(Integer id); | |
16 | + | |
17 | + public Regions getRegions(Integer id); | |
18 | + | |
19 | + public int queryRegionsCount(RegionsQuery query); | |
20 | + | |
21 | + public List<Regions> queryRegions(RegionsQuery query); | |
22 | + | |
23 | +} |
platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/RegionsServiceImpl.java
View file @
10b04f3
1 | +package com.lyms.platform.permission.service.impl; | |
2 | + | |
3 | + | |
4 | +import com.lyms.platform.permission.dao.RegionsMapper; | |
5 | +import com.lyms.platform.permission.model.Regions; | |
6 | +import com.lyms.platform.permission.model.RegionsQuery; | |
7 | +import com.lyms.platform.permission.service.RegionsService; | |
8 | +import org.springframework.beans.factory.annotation.Autowired; | |
9 | +import org.springframework.stereotype.Service; | |
10 | + | |
11 | +import java.util.List; | |
12 | + | |
13 | +@Service | |
14 | +public class RegionsServiceImpl implements RegionsService { | |
15 | + | |
16 | + @Autowired | |
17 | + private RegionsMapper regionsMapper; | |
18 | + | |
19 | + @Override | |
20 | + public void addRegions(Regions obj) { | |
21 | + regionsMapper.addRegions(obj); | |
22 | + } | |
23 | + | |
24 | + @Override | |
25 | + public void updateRegions(Regions obj) { | |
26 | + regionsMapper.updateRegions(obj); | |
27 | + } | |
28 | + | |
29 | + @Override | |
30 | + public void deleteRegions(Integer id) { | |
31 | + regionsMapper.deleteRegions(id); | |
32 | + } | |
33 | + | |
34 | + @Override | |
35 | + public Regions getRegions(Integer id) { | |
36 | + if (id == null) { | |
37 | + return null; | |
38 | + } | |
39 | + return regionsMapper.getRegions(id); | |
40 | + } | |
41 | + | |
42 | + @Override | |
43 | + public int queryRegionsCount(RegionsQuery query) { | |
44 | + return regionsMapper.queryRegionsCount(query); | |
45 | + } | |
46 | + | |
47 | + @Override | |
48 | + public List<Regions> queryRegions(RegionsQuery query) { | |
49 | + if (query.getNeed() != null) { | |
50 | + query.mysqlBuild(regionsMapper.queryRegionsCount(query)); | |
51 | + } | |
52 | + return regionsMapper.queryRegions(query); | |
53 | + } | |
54 | + | |
55 | +} |
platform-biz-service/src/main/resources/mainOrm/Regions.xml
View file @
10b04f3
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | |
3 | +<mapper namespace="com.lymsh.mommybaby.maindata.dao.RegionsMapper"> | |
4 | + | |
5 | + <resultMap id="RegionsResultMap" type="com.lyms.platform.permission.model.Regions"> | |
6 | + <id column="id" property="id" jdbcType="INTEGER"/> | |
7 | + <result column="parent_id" property="parentId" jdbcType="INTEGER"/> | |
8 | + <result column="region_name" property="regionName" jdbcType="VARCHAR"/> | |
9 | + <result column="level" property="level" jdbcType="INTEGER"/> | |
10 | + </resultMap> | |
11 | + | |
12 | + | |
13 | + <insert id="addRegions" parameterType="com.lyms.platform.permission.model.Regions"> | |
14 | +insert into regions (parent_id,region_name,level) values (#{parentId},#{regionName},#{level}) | |
15 | +</insert> | |
16 | + | |
17 | + | |
18 | + <update id="updateRegions" parameterType="com.lyms.platform.permission.model.Regions"> | |
19 | + update regions | |
20 | + <set> | |
21 | + <if test="parentId != null"> | |
22 | + parent_id = #{parentId,jdbcType=INTEGER}, | |
23 | + </if> | |
24 | + <if test="regionName != null and regionName != ''"> | |
25 | + region_name = #{regionName,jdbcType=VARCHAR}, | |
26 | + </if> | |
27 | + <if test="level != null"> | |
28 | + level = #{level,jdbcType=INTEGER}, | |
29 | + </if> | |
30 | + </set> | |
31 | + where id = #{id,jdbcType=INTEGER} | |
32 | + </update> | |
33 | + | |
34 | + | |
35 | + <delete id="deleteRegions" parameterType="java.lang.Integer"> | |
36 | +delete from regions where id = #{id,jdbcType=INTEGER} | |
37 | +</delete> | |
38 | + | |
39 | + | |
40 | + <select id="getRegions" resultMap="RegionsResultMap" parameterType="java.lang.Integer"> | |
41 | +select id,parent_id,region_name,level | |
42 | + from regions where id = #{id,jdbcType=INTEGER} | |
43 | +</select> | |
44 | + | |
45 | + | |
46 | + <sql id="orderAndLimit"> | |
47 | + <if test="sort != null and sort != '' "> | |
48 | + order by ${sort} | |
49 | + <if test="need != null"> | |
50 | + limit #{offset, jdbcType=INTEGER} , #{limit, jdbcType=INTEGER} | |
51 | + </if> | |
52 | + </if> | |
53 | + </sql> | |
54 | + | |
55 | + | |
56 | + <sql id="RegionsCondition"> | |
57 | + <where> | |
58 | + 1 = 1 | |
59 | + <if test="id != null"> | |
60 | + and id = #{id,jdbcType=INTEGER} | |
61 | + </if> | |
62 | + <if test="parentId != null"> | |
63 | + and parent_id = #{parentId,jdbcType=INTEGER} | |
64 | + </if> | |
65 | + <if test="regionName != null and regionName != ''"> | |
66 | + and region_name = #{regionName,jdbcType=VARCHAR} | |
67 | + </if> | |
68 | + <if test="level != null"> | |
69 | + and level = #{level,jdbcType=INTEGER} | |
70 | + </if> | |
71 | + </where> | |
72 | + </sql> | |
73 | + | |
74 | + | |
75 | + <select id="queryRegions" resultMap="RegionsResultMap" parameterType="com.lyms.platform.permission.model.RegionsQuery"> | |
76 | + select id,parent_id,region_name,level | |
77 | + from regions | |
78 | + <include refid="RegionsCondition"/> | |
79 | + <include refid="orderAndLimit"/> | |
80 | + </select> | |
81 | + | |
82 | + | |
83 | + <select id="queryRegionsCount" resultType="int" parameterType="com.lyms.platform.permission.model.RegionsQuery"> | |
84 | + select count(1) from regions | |
85 | + <include refid="RegionsCondition"/> | |
86 | + </select> | |
87 | + | |
88 | + | |
89 | +</mapper> |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RegionController.java
View file @
10b04f3
1 | +package com.lyms.platform.operate.web.controller; | |
2 | + | |
3 | + | |
4 | +import com.lyms.platform.common.base.BaseController; | |
5 | +import com.lyms.platform.common.utils.ResultUtils; | |
6 | +import com.lyms.platform.permission.model.Regions; | |
7 | +import com.lyms.platform.permission.model.RegionsQuery; | |
8 | +import com.lyms.platform.permission.service.RegionsService; | |
9 | +import org.apache.commons.collections.CollectionUtils; | |
10 | +import org.springframework.beans.factory.annotation.Autowired; | |
11 | +import org.springframework.stereotype.Controller; | |
12 | +import org.springframework.web.bind.annotation.RequestMapping; | |
13 | +import org.springframework.web.bind.annotation.RequestMethod; | |
14 | +import org.springframework.web.bind.annotation.RequestParam; | |
15 | + | |
16 | +import javax.servlet.http.HttpServletResponse; | |
17 | +import java.util.ArrayList; | |
18 | +import java.util.HashMap; | |
19 | +import java.util.List; | |
20 | +import java.util.Map; | |
21 | + | |
22 | +/** | |
23 | + * Created by Administrator on 2015/9/17 0017. | |
24 | + */ | |
25 | +@Controller | |
26 | +public class RegionController extends BaseController { | |
27 | + @Autowired | |
28 | + private RegionsService regionsService; | |
29 | + @RequestMapping(value = "/regions",method = RequestMethod.GET) | |
30 | + public void getRegions(@RequestParam("parentId") int parentId, | |
31 | + HttpServletResponse httpServletResponse){ | |
32 | + RegionsQuery regionsQuery= new RegionsQuery(); | |
33 | + regionsQuery.setParentId(parentId); | |
34 | + List<Regions> regionses = regionsService.queryRegions(regionsQuery); | |
35 | + List<Map<String,Object>> list =new ArrayList<Map<String, Object>>(); | |
36 | + if(CollectionUtils.isNotEmpty(regionses)){ | |
37 | + for (Regions regions :regionses){ | |
38 | + Map<String,Object> region=new HashMap<String, Object>(); | |
39 | + region.put("id",regions.getId()); | |
40 | + region.put("level",regions.getLevel()); | |
41 | + region.put("regionName",regions.getRegionName()); | |
42 | + list.add(region); | |
43 | + } | |
44 | + } | |
45 | + ResultUtils.buildSuccessResultAndWrite(httpServletResponse, list); | |
46 | + } | |
47 | +} |