Просмотр исходного кода

Merge branch 'master' of https://git.coding.net/aft/AFT.git

albertshaw лет назад: 8
Родитель
Сommit
15833055c6

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

@@ -45,8 +45,7 @@ public class AdminSuperviseApiController extends CertifyApiController {
 	@RequestMapping(value = "/adminSelectList", method = RequestMethod.GET)
 	public Result adminSelectList() {
 		Result res = new Result();
-		//Map<String, String> aslb = adminService.listAdminSelect();
-
+		res.setData(adminService.listAdminSelect());
 		return res;
 	}
 

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

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.goafanti.admin.bo.AdminDetail;
+import com.goafanti.admin.bo.AdminListBo;
 import com.goafanti.common.model.Admin;
 import com.goafanti.common.model.AdminLocation;
 import com.goafanti.core.mybatis.page.Pagination;
@@ -16,7 +17,7 @@ public interface AdminService {
 
 	Admin selectByPrimaryKey(String key);
 
-	Pagination<Admin> listAdmin(Integer province, Integer number, String mobile, String name, Integer pNo,
+	Pagination<AdminListBo> listAdmin(Integer province, Integer number, String mobile, String name, Integer pNo,
 			Integer pSize);
 
 	int insert(Admin ad);

+ 23 - 6
src/main/java/com/goafanti/admin/service/impl/AdminServiceImpl.java

@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import com.goafanti.admin.bo.AdminDetail;
+import com.goafanti.admin.bo.AdminListBo;
 import com.goafanti.admin.service.AdminService;
 import com.goafanti.common.constant.AFTConstants;
 import com.goafanti.common.dao.AdminLocationMapper;
@@ -49,8 +50,8 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 
 	@SuppressWarnings("unchecked")
 	@Override
-	public Pagination<Admin> listAdmin(Integer province, Integer number, String mobile, String name, Integer pageNo,
-			Integer pageSize) {
+	public Pagination<AdminListBo> listAdmin(Integer province, Integer number, String mobile, String name,
+			Integer pageNo, Integer pageSize) {
 		Map<String, Object> params = new HashMap<>();
 
 		if (StringUtils.isNotBlank(mobile)) {
@@ -72,8 +73,24 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 		if (pageSize == null || pageSize < 0 || pageSize > 10) {
 			pageSize = 10;
 		}
-
-		return (Pagination<Admin>) findPage("findAdminListByPage", "findAdminCount", params, pageNo, pageSize);
+		if (TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
+			return (Pagination<AdminListBo>) findPage("findAdminListByPage", "findAdminCount", params, pageNo,
+					pageSize);
+		} else if (TokenManager.hasRole(AFTConstants.AREAADMIN)) {
+			List<Integer> provinceList = adminLocationMapper
+					.selectProvinceWhereCityIsNullByAdminId(TokenManager.getAdminId());
+			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,
+					pageSize);
+		}
+		return null;
 	}
 
 	@Override
@@ -218,12 +235,12 @@ public class AdminServiceImpl extends BaseMybatisDao<AdminMapper> implements Adm
 		}
 		return map;
 	}
-	
+
 	public static void main(String[] args) {
 		List<Integer> list1 = new ArrayList<>();
 		List<Integer> list2 = new ArrayList<>();
 		list1.addAll(list2);
-		for (Integer i : list1){
+		for (Integer i : list1) {
 			System.out.println(i);
 		}
 		System.out.println(list1.size());

+ 3 - 1
src/main/java/com/goafanti/common/dao/AdminMapper.java

@@ -2,6 +2,8 @@ package com.goafanti.common.dao;
 
 import java.util.List;
 
+import org.apache.ibatis.annotations.Param;
+
 import com.goafanti.common.model.Admin;
 import com.goafanti.common.model.Role;
 
@@ -54,6 +56,6 @@ public interface AdminMapper {
 
 	List<Admin> listAdminSelectBySuperAdmin();
 
-	List<Admin> listAdminSelectByAreaAdmin(List<Integer> provinceList, List<Integer> cityList);
+	List<Admin> listAdminSelectByAreaAdmin(@Param("provinceList")List<Integer> provinceList, @Param("cityList")List<Integer> cityList);
 
 }

+ 81 - 1
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -322,7 +322,7 @@
    	where id <![CDATA[ <> ]]> '1'
    </select>
    
-   <select id="listAdminSelectByAreaAdmin" parameterType="Map" resultMap="BaseResultMap"> 
+   <select id="listAdminSelectByAreaAdmin"  resultMap="BaseResultMap"> 
     select 
     	a.id, a.name, a.mobile,
     	a.create_time as createTime, a.number,  aa.name as superior
@@ -349,4 +349,84 @@
 			</foreach>
 	</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
+    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 1 =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>
+    <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>
+	group by a.id
+    order by a.number 
+    <if test="page_sql!=null">
+			${page_sql}
+	</if>
+  </select>
+  
+  <select id = "findAreaAdminCount" parameterType="java.lang.String" resultType="java.lang.Integer">
+   select count(1) from ( select count(1) 
+   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>
+    <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>
+	group by a.id
+	) tem
+  </select>
 </mapper>