Browse Source

客户管理

wanghui 8 years ago
parent
commit
79c996069d

+ 14 - 0
src/main/java/com/goafanti/admin/bo/AdminListBo.java

@@ -39,6 +39,12 @@ public class AdminListBo {
 	 * 所在省份
 	 */
 	private String	province;
+	
+	/**
+	 * 所在市 
+	 */
+	private String city;
+	
 	/**
 	 * 职位
 	 */
@@ -124,6 +130,14 @@ public class AdminListBo {
 		this.province = province;
 	}
 
+	public String getCity() {
+		return city;
+	}
+
+	public void setCity(String city) {
+		this.city = city;
+	}
+
 	public String getPosition() {
 		return position;
 	}

+ 3 - 11
src/main/java/com/goafanti/admin/controller/AdminSuperviseApiController.java

@@ -156,13 +156,6 @@ public class AdminSuperviseApiController extends CertifyApiController {
 			Admin ad = new Admin();
 			BeanUtils.copyProperties(admin, ad);
 			ad.setId(UUID.randomUUID().toString());
-			res = disposeAdminLocationList(res, jo, ad);
-			if (!res.getError().isEmpty()) {
-				return res;
-			}
-
-			List<AdminLocation> adminLocationList = (List<AdminLocation>) res.getData();
-
 			Calendar now = Calendar.getInstance();
 			now.set(Calendar.MILLISECOND, 0);
 
@@ -171,7 +164,7 @@ public class AdminSuperviseApiController extends CertifyApiController {
 				ad.setPassword(AFTConstants.INITIALPASSWORD);
 			}
 			ad.setPassword(passwordUtil.getEncryptPwd(ad));
-			res.setData(adminService.insertNewAdmin(ad, adminLocationList));
+			res.setData(adminService.insertNewAdmin(ad));
 		}
 
 		return res;
@@ -180,7 +173,6 @@ 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();
@@ -221,14 +213,14 @@ public class AdminSuperviseApiController extends CertifyApiController {
 			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, adminLocationList));
+			res.setData(adminService.updateByPrimaryKeySelective(ad, roles));
 		}
 		return res;
 	}

+ 2 - 2
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, List<AdminLocation> adminLocationList);
+	int updateByPrimaryKeySelective(Admin ad, List<String> roleIds);
 
 	int updateByPrimaryKey(Admin a);
 
@@ -58,7 +58,7 @@ public interface AdminService {
 
 	Map<String, String> selectTechBroder();
 
-	int insertNewAdmin(Admin ad, List<AdminLocation> adminLocationList);
+	int insertNewAdmin(Admin ad);
 
 	Map<String, String> listAdminSelect();
 

+ 4 - 34
src/main/java/com/goafanti/admin/service/impl/AdminServiceImpl.java

@@ -1,6 +1,5 @@
 package com.goafanti.admin.service.impl;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -73,32 +72,10 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 			pageSize = 10;
 		}
 		if (province != null) {
-			List<Integer> provinceList = new ArrayList<>();
-			provinceList.add(province);
-			params.put("provinceList", provinceList);
+			params.put("province", province);
 		}
-		if (TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
-			return (Pagination<AdminListBo>) findPage("findAreaAdminListByPage", "findAreaAdminCount", params, pageNo,
-					pageSize);
-		} else if (TokenManager.hasRole(AFTConstants.AREAADMIN)) {
-			List<Integer> provinceList = adminLocationMapper
-					.selectProvinceWhereCityIsNullByAdminId(TokenManager.getAdminId());
-			if (province != null && provinceList.contains(province)) {
-				provinceList = new ArrayList<>();
-				provinceList.add(province);
-			}
-			List<Integer> cityList = adminLocationMapper.selectCityByAdminId(TokenManager.getAdminId());
-			provinceList.addAll(cityList);
-			if (null != provinceList && provinceList.size() > 0) {
-				params.put("provinceList", provinceList);
-			}
-			if (null != cityList && cityList.size() > 0) {
-				params.put("cityList", cityList);
-			}
-			return (Pagination<AdminListBo>) findPage("findAreaAdminListByPage", "findAreaAdminCount", params, pageNo,
+		return (Pagination<AdminListBo>) findPage("findAdminListByPage", "findAdminCount", params, pageNo,
 					pageSize);
-		}
-		return null;
 	}
 
 	@Override
@@ -107,7 +84,7 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 	}
 
 	@Override
-	public int updateByPrimaryKeySelective(Admin ad, List<String> roleIds, List<AdminLocation> adminLocationList) {
+	public int updateByPrimaryKeySelective(Admin ad, List<String> roleIds) {
 		Map<String, Object> params = new HashMap<>();
 		params.put("uid", ad.getId());
 		params.put("roles", roleIds);
@@ -119,10 +96,6 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 			}
 			TokenManager.clearUserAuthByUserId(ad.getId());
 		}
-		adminLocationMapper.deleteByAdminId(ad.getId());
-		if (null != adminLocationList && adminLocationList.size() > 0) {
-			adminLocationMapper.insertBatch(adminLocationList);
-		}
 		return adminMapper.updateByPrimaryKeySelective(ad);
 	}
 
@@ -220,10 +193,7 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 	}
 
 	@Override
-	public int insertNewAdmin(Admin ad, List<AdminLocation> adminLocationList) {
-		if (null != adminLocationList && adminLocationList.size() > 0) {
-			adminLocationMapper.insertBatch(adminLocationList);
-		}
+	public int insertNewAdmin(Admin ad) {
 		return adminMapper.insert(ad);
 	}
 

+ 14 - 84
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -319,42 +319,18 @@
   	select 
    		 a.number, a.mobile, a.name, 
    		 a.position, a.email, a.id,
-   		 a.create_time as createTime, GROUP_CONCAT(DISTINCT(al.province)) AS province,
-   		 aa.name as superior, a.superior_id as superiorId
-    from admin a 
-    left join admin_location al on a.id = al.admin_id
-    left join admin aa on aa.id = a.superior_id
-    where a.id <![CDATA[ <> ]]> '1'
-    <if test = "mobile != null"> 
-    	and a.mobile = #{mobile,jdbcType=VARCHAR}
-    </if>
-    <if test = "name != null"> 
-    	and a.name = #{name,jdbcType=VARCHAR}
-    </if>
-    <if test = "number != null">
-    	and a.number = #{number,jdbcType=INTEGER}
-    </if>
-    group by a.id  
-    order by a.number 
-    <if test="page_sql!=null">
-			${page_sql}
-	</if>
-  </select>
-  
-  <select id= "findAreaAdminListByPage" parameterType="java.lang.String" resultType="com.goafanti.admin.bo.AdminListBo" >
-  	select 
-   		 a.number, a.mobile, a.name, 
-   		 a.position, a.email, a.id,
-   		 a.create_time as createTime,
-   		 aa.name as superior, GROUP_CONCAT(DISTINCT(al.province)) AS province,
+   		 a.province,
+   		 a.city,
+   		 a.create_time as createTime, 
+   		 aa.name as superior, 
    		 a.superior_id as superiorId,
-   		 dm.id as departmentId,
+   		 a.department_id as departmentId,
    		 dm.name as departmentName
     from admin a 
     left join admin_location al on a.id = al.admin_id
     left join admin aa on aa.id = a.superior_id
     left join department_management dm on a.department_id = dm.id
-    where 1 =1
+    where a.id <![CDATA[ <> ]]> '1'
     <if test = "mobile != null"> 
     	and a.mobile = #{mobile,jdbcType=VARCHAR}
     </if>
@@ -364,25 +340,9 @@
     <if test = "number != null">
     	and a.number = #{number,jdbcType=INTEGER}
     </if>
-    <if test="provinceList != null">
-	   and  al.province in
-	    <foreach collection="provinceList" item="plist"  open="(" separator="," close=")">
-			#{plist}
-		</foreach>
-	</if>
-	<if test = "provinceList != null and cityList != null">
-	or 
-	</if>
-	<if test="cityList != null">
-		<if test="provinceList == null">
-			and
-		</if>
-			al.city in 
-			<foreach collection="cityList" item="clist"  open="(" separator="," close=")">
-				#{clist}
-			</foreach>
-	</if>
-	group by a.id
+    <if test = "province != null">
+    	and a.province = #{province,jdbcType=VARCHAR}
+    </if>
     order by a.number 
     <if test="page_sql!=null">
 			${page_sql}
@@ -390,8 +350,8 @@
   </select>
   
   <select id = "findAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
-   select count(1) from admin
-     where id <![CDATA[ <> ]]> '1'
+   	select count(1) from admin
+    where id <![CDATA[ <> ]]> '1'
     <if test = "mobile != null"> 
     	and mobile = #{mobile,jdbcType=VARCHAR}
     </if>
@@ -401,41 +361,11 @@
     <if test = "number != null">
     	and number = #{number,jdbcType=INTEGER}
     </if>
-  </select>
-  
-  <select id = "findAreaAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
-   select count(distinct(a.number))  
-   from admin a 
-    left join admin_location al on a.id = al.admin_id
-    where 1 = 1
-    <if test = "mobile != null"> 
-    	and a.mobile = #{mobile,jdbcType=VARCHAR}
+    <if test = "province != null">
+    	and a.province = #{province,jdbcType=VARCHAR}
     </if>
-    <if test = "name != null"> 
-    	and a.name = #{name,jdbcType=VARCHAR}
-    </if>
-    <if test = "number != null">
-    	and a.number = #{number,jdbcType=INTEGER}
-    </if>
-    <if test="provinceList != null">
-	   and  al.province in
-	    <foreach collection="provinceList" item="plist"  open="(" separator="," close=")">
-			#{plist}
-		</foreach>
-	</if>
-	<if test = "provinceList != null &amp;&amp; cityList != null">
-	or 
-	</if>
-	<if test="cityList != null">
-		<if test="provinceList == null">
-			and
-		</if>
-			al.city in 
-			<foreach collection="cityList" item="clist"  open="(" separator="," close=")">
-				#{clist}
-			</foreach>
-	</if>
   </select>
+
   
   <select id="listAdminByName" parameterType="java.lang.String" resultMap="BaseResultMap">
 	select id,name from admin where name like concat('%',#{name},'%')