Browse Source

修改bug

傅行帆 6 years ago
parent
commit
63e05a2796

+ 12
- 1
CODE/smart-community/operate-api/src/main/java/com/community/huiju/controller/CommunityController.java View File

17
 import org.springframework.web.bind.annotation.RequestParam;
17
 import org.springframework.web.bind.annotation.RequestParam;
18
 import org.springframework.web.bind.annotation.RestController;
18
 import org.springframework.web.bind.annotation.RestController;
19
 
19
 
20
+import javax.validation.Valid;
20
 import java.util.List;
21
 import java.util.List;
21
 import java.util.Map;
22
 import java.util.Map;
22
 
23
 
69
 					"communityName:社区名称,communityAlias:小区别名, provinceId:省份id,cityId:城市id,districtId:区县id,longitude: 经度,latitude: 纬度,userName:物业端用户名,loginName:物业端登录名")
70
 					"communityName:社区名称,communityAlias:小区别名, provinceId:省份id,cityId:城市id,districtId:区县id,longitude: 经度,latitude: 纬度,userName:物业端用户名,loginName:物业端登录名")
70
 	})
71
 	})
71
 	@RequestMapping(value = "/community/add",method = RequestMethod.POST)
72
 	@RequestMapping(value = "/community/add",method = RequestMethod.POST)
72
-	public ResponseBean addCommunity(@RequestBody ToCommunities toCommunities){
73
+	public ResponseBean addCommunity(@RequestBody @Valid ToCommunities toCommunities){
73
 		ResponseBean responseBean = new ResponseBean();
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
 		Integer size = communityService.addCommunity(toCommunities);
80
 		Integer size = communityService.addCommunity(toCommunities);
75
 		responseBean.addSuccess(size);
81
 		responseBean.addSuccess(size);
76
 		return responseBean;
82
 		return responseBean;
96
 	@RequestMapping(value = "/community/update",method = RequestMethod.POST)
102
 	@RequestMapping(value = "/community/update",method = RequestMethod.POST)
97
 	public ResponseBean updateCommunityById(@RequestBody ToCommunities toCommunities){
103
 	public ResponseBean updateCommunityById(@RequestBody ToCommunities toCommunities){
98
 		ResponseBean responseBean = new ResponseBean();
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
 		String message = communityService.updateCommunityById(toCommunities);
110
 		String message = communityService.updateCommunityById(toCommunities);
100
 		if (message.equals(Constant.SUCCESS)){
111
 		if (message.equals(Constant.SUCCESS)){
101
 			responseBean.addSuccess(message);
112
 			responseBean.addSuccess(message);

+ 47
- 6
CODE/smart-community/operate-api/src/main/java/com/community/huiju/model/ToCommunities.java View File

1
 package com.community.huiju.model;
1
 package com.community.huiju.model;
2
 
2
 
3
+import javax.validation.constraints.NotBlank;
4
+import javax.validation.constraints.NotNull;
3
 import java.util.Date;
5
 import java.util.Date;
4
 
6
 
5
 public class ToCommunities {
7
 public class ToCommunities {
6
     private Integer id;
8
     private Integer id;
7
-
9
+    
10
+    @NotBlank(message = "社区名称不能为空!")
8
     private String communityName;
11
     private String communityName;
9
 
12
 
10
     private String communityAlias;
13
     private String communityAlias;
11
-
14
+    
15
+    @NotNull(message = "所在省不能为空!")
12
     private Integer provinceId;
16
     private Integer provinceId;
13
-
17
+    
18
+    @NotNull(message = "所在市不能为空!")
14
     private Integer cityId;
19
     private Integer cityId;
15
-
20
+    
21
+    @NotNull(message = "所在区县乡不能为空!")
16
     private Integer districtId;
22
     private Integer districtId;
17
-
23
+    
24
+    @NotBlank(message = "经纬度不能为空!")
18
     private String longitude;
25
     private String longitude;
19
-
26
+    
27
+    @NotBlank(message = "经纬度不能为空!")
20
     private String latitude;
28
     private String latitude;
21
     
29
     
30
+    @NotBlank(message = "管理员姓名不能为空!")
22
     private String userName;
31
     private String userName;
23
     
32
     
33
+    @NotBlank(message = "管理员账号不能为空!")
24
     private String loginName;
34
     private String loginName;
25
     
35
     
26
     private Integer createUser;
36
     private Integer createUser;
30
     private Integer updateUser;
40
     private Integer updateUser;
31
     
41
     
32
     private Date updateDate;
42
     private Date updateDate;
43
+    
44
+    private String province;
45
+    
46
+    private String city;
47
+    
48
+    private String district;
49
+    
33
 
50
 
34
     public Integer getId() {
51
     public Integer getId() {
35
         return id;
52
         return id;
142
     public void setUpdateDate(Date updateDate) {
159
     public void setUpdateDate(Date updateDate) {
143
         this.updateDate = updateDate;
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 View File

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

+ 56
- 9
CODE/smart-community/operate-api/src/main/resources/mapper/ToCommunitiesMapper.xml View File

16
     <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
16
     <result column="create_date" property="createDate" jdbcType="TIMESTAMP" />
17
     <result column="update_user" property="updateUser" jdbcType="INTEGER" />
17
     <result column="update_user" property="updateUser" jdbcType="INTEGER" />
18
     <result column="update_date" property="updateDate" jdbcType="TIMESTAMP" />
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
   </resultMap>
22
   </resultMap>
20
   <sql id="Base_Column_List" >
23
   <sql id="Base_Column_List" >
21
     id, community_name, community_alias, province_id, city_id, district_id, longitude,
24
     id, community_name, community_alias, province_id, city_id, district_id, longitude,
72
       <if test="loginName != null" >
75
       <if test="loginName != null" >
73
         login_name,
76
         login_name,
74
       </if>
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
     </trim>
90
     </trim>
76
     <trim prefix="values (" suffix=")" suffixOverrides="," >
91
     <trim prefix="values (" suffix=")" suffixOverrides="," >
77
       <if test="id != null" >
92
       <if test="id != null" >
104
       <if test="loginName != null" >
119
       <if test="loginName != null" >
105
         #{loginName,jdbcType=VARCHAR},
120
         #{loginName,jdbcType=VARCHAR},
106
       </if>
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
     </trim>
134
     </trim>
108
   </insert>
135
   </insert>
109
   <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.ToCommunities" >
136
   <update id="updateByPrimaryKeySelective" parameterType="com.community.huiju.model.ToCommunities" >
152
   </update>
179
   </update>
153
 
180
 
154
   <select id="selectByCommunityName" resultMap="BaseResultMap" parameterType="com.community.huiju.model.ToCommunities" >
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
     where 1=1
205
     where 1=1
159
     <if test="communityName != null and communityName != ''" >
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
     </if>
208
     </if>
162
     <if test="id != null and id != ''" >
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
     </if>
211
     </if>
165
     <if test="provinceId != null and provinceId != ''" >
212
     <if test="provinceId != null and provinceId != ''" >
166
-      and province_id = #{provinceId,jdbcType=INTEGER}
213
+      and c.province_id = #{provinceId,jdbcType=INTEGER}
167
     </if>
214
     </if>
168
     <if test="cityId != null and cityId != ''" >
215
     <if test="cityId != null and cityId != ''" >
169
-      and city_id = #{cityId,jdbcType=INTEGER}
216
+      and c.city_id = #{cityId,jdbcType=INTEGER}
170
     </if>
217
     </if>
171
     <if test="districtId != null and districtId != ''" >
218
     <if test="districtId != null and districtId != ''" >
172
-      and district_id = #{districtId,jdbcType=INTEGER}
219
+      and c.district_id = #{districtId,jdbcType=INTEGER}
173
     </if>
220
     </if>
174
-    order by create_date desc
221
+    order by c.create_date desc
175
   </select>
222
   </select>
176
 </mapper>
223
 </mapper>

+ 1
- 1
VUECODE/smart-operate-manage/src/store/modules/community.js View File

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

+ 16
- 9
VUECODE/smart-operate-manage/src/views/community/communityTable.vue View File

48
       </el-table-column>
48
       </el-table-column>
49
       <el-table-column label="所在地区" align="center">
49
       <el-table-column label="所在地区" align="center">
50
         <template slot-scope="scope">
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
         </template>
52
         </template>
53
       </el-table-column>
53
       </el-table-column>
54
       <el-table-column label="物业人员数量" align="center">
54
       <el-table-column label="物业人员数量" align="center">
317
       })
317
       })
318
     },
318
     },
319
     getCityList() {
319
     getCityList() {
320
+      this.listQuery.cityId = undefined
321
+      this.listQuery.districtId = undefined
320
       this.FetchCityList(this.listQuery.provinceId).then(() => {
322
       this.FetchCityList(this.listQuery.provinceId).then(() => {
321
       }).catch(() => {
323
       }).catch(() => {
322
         console.log('get list error')
324
         console.log('get list error')
397
     createData() {
399
     createData() {
398
       this.$refs['dataForm'].validate((valid) => {
400
       this.$refs['dataForm'].validate((valid) => {
399
         if (valid) {
401
         if (valid) {
400
-          this.CreateCommunity(this.detail).then(() => {
402
+          this.CreateCommunity(this.detail).then((res) => {
401
             this.dialogFormVisible = false
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
       })