傅行帆 6 年 前
コミット
63e05a2796

+ 12
- 1
CODE/smart-community/operate-api/src/main/java/com/community/huiju/controller/CommunityController.java ファイルの表示

@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
17 17
 import org.springframework.web.bind.annotation.RequestParam;
18 18
 import org.springframework.web.bind.annotation.RestController;
19 19
 
20
+import javax.validation.Valid;
20 21
 import java.util.List;
21 22
 import java.util.Map;
22 23
 
@@ -69,8 +70,13 @@ public class CommunityController {
69 70
 					"communityName:社区名称,communityAlias:小区别名, provinceId:省份id,cityId:城市id,districtId:区县id,longitude: 经度,latitude: 纬度,userName:物业端用户名,loginName:物业端登录名")
70 71
 	})
71 72
 	@RequestMapping(value = "/community/add",method = RequestMethod.POST)
72
-	public ResponseBean addCommunity(@RequestBody ToCommunities toCommunities){
73
+	public ResponseBean addCommunity(@RequestBody @Valid ToCommunities toCommunities){
73 74
 		ResponseBean responseBean = new ResponseBean();
75
+		String telRegex = "[1][3578]\\d{9}";
76
+		if (!toCommunities.getLoginName().matches(telRegex)){
77
+			responseBean.addError("请输入正确格式的手机号!");
78
+			return responseBean;
79
+		}
74 80
 		Integer size = communityService.addCommunity(toCommunities);
75 81
 		responseBean.addSuccess(size);
76 82
 		return responseBean;
@@ -96,6 +102,11 @@ public class CommunityController {
96 102
 	@RequestMapping(value = "/community/update",method = RequestMethod.POST)
97 103
 	public ResponseBean updateCommunityById(@RequestBody ToCommunities toCommunities){
98 104
 		ResponseBean responseBean = new ResponseBean();
105
+		String telRegex = "[1][3578]\\d{9}";
106
+		if (!toCommunities.getLoginName().matches(telRegex)){
107
+			responseBean.addError("请输入正确格式的手机号!");
108
+			return responseBean;
109
+		}
99 110
 		String message = communityService.updateCommunityById(toCommunities);
100 111
 		if (message.equals(Constant.SUCCESS)){
101 112
 			responseBean.addSuccess(message);

+ 47
- 6
CODE/smart-community/operate-api/src/main/java/com/community/huiju/model/ToCommunities.java ファイルの表示

@@ -1,26 +1,36 @@
1 1
 package com.community.huiju.model;
2 2
 
3
+import javax.validation.constraints.NotBlank;
4
+import javax.validation.constraints.NotNull;
3 5
 import java.util.Date;
4 6
 
5 7
 public class ToCommunities {
6 8
     private Integer id;
7
-
9
+    
10
+    @NotBlank(message = "社区名称不能为空!")
8 11
     private String communityName;
9 12
 
10 13
     private String communityAlias;
11
-
14
+    
15
+    @NotNull(message = "所在省不能为空!")
12 16
     private Integer provinceId;
13
-
17
+    
18
+    @NotNull(message = "所在市不能为空!")
14 19
     private Integer cityId;
15
-
20
+    
21
+    @NotNull(message = "所在区县乡不能为空!")
16 22
     private Integer districtId;
17
-
23
+    
24
+    @NotBlank(message = "经纬度不能为空!")
18 25
     private String longitude;
19
-
26
+    
27
+    @NotBlank(message = "经纬度不能为空!")
20 28
     private String latitude;
21 29
     
30
+    @NotBlank(message = "管理员姓名不能为空!")
22 31
     private String userName;
23 32
     
33
+    @NotBlank(message = "管理员账号不能为空!")
24 34
     private String loginName;
25 35
     
26 36
     private Integer createUser;
@@ -30,6 +40,13 @@ public class ToCommunities {
30 40
     private Integer updateUser;
31 41
     
32 42
     private Date updateDate;
43
+    
44
+    private String province;
45
+    
46
+    private String city;
47
+    
48
+    private String district;
49
+    
33 50
 
34 51
     public Integer getId() {
35 52
         return id;
@@ -142,4 +159,28 @@ public class ToCommunities {
142 159
     public void setUpdateDate(Date updateDate) {
143 160
         this.updateDate = updateDate;
144 161
     }
162
+    
163
+    public String getProvince() {
164
+        return province;
165
+    }
166
+    
167
+    public void setProvince(String province) {
168
+        this.province = province;
169
+    }
170
+    
171
+    public String getCity() {
172
+        return city;
173
+    }
174
+    
175
+    public void setCity(String city) {
176
+        this.city = city;
177
+    }
178
+    
179
+    public String getDistrict() {
180
+        return district;
181
+    }
182
+    
183
+    public void setDistrict(String district) {
184
+        this.district = district;
185
+    }
145 186
 }

+ 1
- 0
CODE/smart-community/operate-api/src/main/java/com/community/huiju/service/impl/CommunityServiceImpl.java ファイルの表示

@@ -57,6 +57,7 @@ public class CommunityServiceImpl implements CommunityServiceI {
57 57
 	
58 58
 	@Override
59 59
 	public Integer addCommunity(ToCommunities toCommunities) {
60
+		toCommunities.setCreateDate(new Date());
60 61
 		Integer size = toCommunitiesMapper.insertSelective(toCommunities);
61 62
 		if (size < 1){
62 63
 			return 0;

+ 56
- 9
CODE/smart-community/operate-api/src/main/resources/mapper/ToCommunitiesMapper.xml ファイルの表示

@@ -16,6 +16,9 @@
16 16
     <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
17 17
     <result column="update_user" property="updateUser" jdbcType="INTEGER" />
18 18
     <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
19
+    <result column="province" property="province" jdbcType="VARCHAR" />
20
+    <result column="city" property="city" jdbcType="VARCHAR" />
21
+    <result column="district" property="district" jdbcType="VARCHAR" />
19 22
   </resultMap>
20 23
   <sql id="Base_Column_List" >
21 24
     id, community_name, community_alias, province_id, city_id, district_id, longitude,
@@ -72,6 +75,18 @@
72 75
       <if test="loginName != null" >
73 76
         login_name,
74 77
       </if>
78
+      <if test="createUser != null" >
79
+        create_user,
80
+      </if>
81
+      <if test="createDate != null" >
82
+        create_date,
83
+      </if>
84
+      <if test="updateUser != null" >
85
+        update_user,
86
+      </if>
87
+      <if test="updateDate != null" >
88
+        update_date,
89
+      </if>
75 90
     </trim>
76 91
     <trim prefix="values (" suffix=")" suffixOverrides="," >
77 92
       <if test="id != null" >
@@ -104,6 +119,18 @@
104 119
       <if test="loginName != null" >
105 120
         #{loginName,jdbcType=VARCHAR},
106 121
       </if>
122
+      <if test="createUser != null" >
123
+        #{createUser,jdbcType=INTEGER},
124
+      </if>
125
+      <if test="createDate != null" >
126
+        #{createDate,jdbcType=TIMESTAMP},
127
+      </if>
128
+      <if test="updateUser != null" >
129
+        #{updateUser,jdbcType=INTEGER},
130
+      </if>
131
+      <if test="updateDate != null" >
132
+        #{updateDate,jdbcType=TIMESTAMP},
133
+      </if>
107 134
     </trim>
108 135
   </insert>
109 136
   <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.ToCommunities" >
@@ -152,25 +179,45 @@
152 179
   </update>
153 180
 
154 181
   <select id="selectByCommunityName" resultMap="BaseResultMap" parameterType="com.community.huiju.model.ToCommunities" >
155
-    select
156
-    <include refid="Base_Column_List" />
157
-    from to_communities
182
+    SELECT
183
+      c.id,
184
+      c.community_name,
185
+      c.community_alias,
186
+      c.province_id,
187
+      c.city_id,
188
+      c.district_id,
189
+      c.longitude,
190
+      c.latitude,
191
+      c.user_name,
192
+      c.login_name,
193
+      c.create_user,
194
+      c.create_date,
195
+      c.update_user,
196
+      c.update_date,
197
+      n.province,
198
+      a.city,
199
+      t.district
200
+    FROM
201
+      to_communities c
202
+    LEFT JOIN sys_nation n ON c.province_id = n.id
203
+    LEFT JOIN sys_nation a ON c.city_id = a.id
204
+    LEFT JOIN sys_nation t ON c.district_id = t.id
158 205
     where 1=1
159 206
     <if test="communityName != null and communityName != ''" >
160
-      and community_name like concat('%',#{communityName,jdbcType=VARCHAR},'%')
207
+      and c.community_name like concat('%',#{communityName,jdbcType=VARCHAR},'%')
161 208
     </if>
162 209
     <if test="id != null and id != ''" >
163
-      and id like concat('%',#{id,jdbcType=INTEGER},'%')
210
+      and c.id like concat('%',#{id,jdbcType=INTEGER},'%')
164 211
     </if>
165 212
     <if test="provinceId != null and provinceId != ''" >
166
-      and province_id = #{provinceId,jdbcType=INTEGER}
213
+      and c.province_id = #{provinceId,jdbcType=INTEGER}
167 214
     </if>
168 215
     <if test="cityId != null and cityId != ''" >
169
-      and city_id = #{cityId,jdbcType=INTEGER}
216
+      and c.city_id = #{cityId,jdbcType=INTEGER}
170 217
     </if>
171 218
     <if test="districtId != null and districtId != ''" >
172
-      and district_id = #{districtId,jdbcType=INTEGER}
219
+      and c.district_id = #{districtId,jdbcType=INTEGER}
173 220
     </if>
174
-    order by create_date desc
221
+    order by c.create_date desc
175 222
   </select>
176 223
 </mapper>

+ 1
- 1
VUECODE/smart-operate-manage/src/store/modules/community.js ファイルの表示

@@ -82,7 +82,7 @@ const community = {
82 82
     CreateCommunity({ commit }, datail) {
83 83
       return new Promise((resolve, reject) => {
84 84
         createCommunity(datail).then(response => {
85
-          resolve()
85
+          resolve(response)
86 86
         }).catch(error => {
87 87
           reject(error)
88 88
         })

+ 16
- 9
VUECODE/smart-operate-manage/src/views/community/communityTable.vue ファイルの表示

@@ -48,7 +48,7 @@
48 48
       </el-table-column>
49 49
       <el-table-column label="所在地区" align="center">
50 50
         <template slot-scope="scope">
51
-          <span>{{ scope.row.provinceId }}{{ scope.row.cityId }}{{ scope.row.districtId }}</span>
51
+          <span>{{ scope.row.province }}{{ scope.row.city }}{{ scope.row.district }}</span>
52 52
         </template>
53 53
       </el-table-column>
54 54
       <el-table-column label="物业人员数量" align="center">
@@ -317,6 +317,8 @@ export default {
317 317
       })
318 318
     },
319 319
     getCityList() {
320
+      this.listQuery.cityId = undefined
321
+      this.listQuery.districtId = undefined
320 322
       this.FetchCityList(this.listQuery.provinceId).then(() => {
321 323
       }).catch(() => {
322 324
         console.log('get list error')
@@ -397,15 +399,20 @@ export default {
397 399
     createData() {
398 400
       this.$refs['dataForm'].validate((valid) => {
399 401
         if (valid) {
400
-          this.CreateCommunity(this.detail).then(() => {
402
+          this.CreateCommunity(this.detail).then((res) => {
401 403
             this.dialogFormVisible = false
402
-            this.$notify({
403
-              title: '成功',
404
-              message: '创建成功',
405
-              type: 'success',
406
-              duration: 2000
407
-            })
408
-            this.getList()
404
+            if (res.code == 0) {
405
+              this.$message({
406
+                message: '创建成功',
407
+                type: 'success'
408
+              })
409
+              this.getList()
410
+            }else if (res.code == 0) {
411
+              this.$message({
412
+                message: res.message,
413
+                type: 'warning'
414
+              })
415
+            }
409 416
           })
410 417
         }
411 418
       })