Antiloveg 8 years ago
parent
commit
7cc512e70b

+ 7 - 1
src/main/java/com/goafanti/admin/controller/AdminSuperviseApiController.java

@@ -135,6 +135,7 @@ public class AdminSuperviseApiController extends CertifyApiController {
 	/**
 	 * 修改管理员信息
 	 */
+	@SuppressWarnings("unchecked")
 	@RequestMapping(value = "/updateAdmin", method = RequestMethod.POST)
 	public Result updateAdmin(@RequestParam(value = "roles[]", required = false) String[] roleIds, String data) {
 		Result res = new Result();
@@ -171,13 +172,18 @@ public class AdminSuperviseApiController extends CertifyApiController {
 			}
 			Admin ad = new Admin();
 			BeanUtils.copyProperties(admin, ad);
+			res = disposeAdminLocationList(res, jo, ad);
+			if (!res.getError().isEmpty()) {
+				return res;
+			}
+			List<AdminLocation> adminLocationList = (List<AdminLocation>) res.getData();
 			List<String> roles = new ArrayList<String>();
 			if (roleIds != null && roleIds.length > 0) {
 				for (String role : roleIds) {
 					roles.add(role);
 				}
 			}
-			res.setData(adminService.updateByPrimaryKeySelective(ad, roles));
+			res.setData(adminService.updateByPrimaryKeySelective(ad, roles, adminLocationList));
 		}
 		return res;
 	}

+ 1 - 1
src/main/java/com/goafanti/admin/service/AdminService.java

@@ -22,7 +22,7 @@ public interface AdminService {
 
 	int insert(Admin ad);
 
-	int updateByPrimaryKeySelective(Admin ad, List<String> roleIds);
+	int updateByPrimaryKeySelective(Admin ad, List<String> roleIds, List<AdminLocation> adminLocationList);
 
 	int updateByPrimaryKey(Admin a);
 

+ 3 - 2
src/main/java/com/goafanti/admin/service/impl/AdminServiceImpl.java

@@ -98,7 +98,7 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 	}
 
 	@Override
-	public int updateByPrimaryKeySelective(Admin ad, List<String> roleIds) {
+	public int updateByPrimaryKeySelective(Admin ad, List<String> roleIds, List<AdminLocation> adminLocationList) {
 		Map<String, Object> params = new HashMap<>();
 		params.put("uid", ad.getId());
 		params.put("roles", roleIds);
@@ -110,7 +110,8 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 			}
 			TokenManager.clearUserAuthByUserId(ad.getId());
 		}
-
+		adminLocationMapper.deleteByAdminId(ad.getId());
+		adminLocationMapper.insertBatch(adminLocationList);
 		return adminMapper.updateByPrimaryKeySelective(ad);
 	}
 

+ 2 - 0
src/main/java/com/goafanti/common/dao/AdminLocationMapper.java

@@ -26,4 +26,6 @@ public interface AdminLocationMapper {
 
 	List<AdminLocationBo> selectByAdminId(String adminId);
 
+	int deleteByAdminId(String id);
+
 }

+ 5 - 0
src/main/java/com/goafanti/common/mapper/AdminLocationMapper.xml

@@ -118,4 +118,9 @@
 		admin_id = #{adminId,jdbcType=VARCHAR} 
 	GROUP BY province
   </select>
+  
+  <select id="deleteByAdminId" parameterType="java.lang.String">
+  	delete from admin_location
+  	where admin_id = #{adminId,jdbcType=VARCHAR}
+  </select>
 </mapper>