Browse Source

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

albertshaw 8 years ago
parent
commit
0b57796440

+ 25 - 7
src/main/java/com/goafanti/admin/controller/AdminApiController.java

@@ -289,9 +289,27 @@ public class AdminApiController extends CertifyApiController {
 	 * 管理员"我的客户"列表
 	 */
 	@RequestMapping(value = "/customer", method = RequestMethod.GET)
-	public Result getCustomer() {
+	public Result getCustomer(Integer number, String mobile, Integer auditStatus, String auditName, String email,
+			String startCreateTime, String endCreateTime, Integer type, String pageNo, String pageSize) {
 		Result res = new Result();
-		res.setData(userService.selectUserByAid(TokenManager.getAdminId()));
+		if (null == type) {
+			res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "用户类型", "用户类型"));
+			return res;
+		}
+		if (!UserType.PERSONAL.getCode().equals(type) && !UserType.ORGANIZATION.getCode().equals(type)) {
+			res.getError().add(buildError(ErrorConstants.PARAM_ERROR, "用户类型", "用户类型"));
+			return res;
+		}
+		Integer pNo = 1;
+		Integer pSize = 10;
+		if (StringUtils.isNumeric(pageSize)) {
+			pSize = Integer.parseInt(pageSize);
+		}
+		if (StringUtils.isNumeric(pageNo)) {
+			pNo = Integer.parseInt(pageNo);
+		}
+		res.setData(userService.selectUserByAid(number, mobile, auditStatus, auditName, email,
+				TokenManager.getAdminId(), startCreateTime, endCreateTime, type, pNo, pSize));
 		return res;
 	}
 
@@ -430,7 +448,7 @@ public class AdminApiController extends CertifyApiController {
 	 * 个人用户列表
 	 */
 	@RequestMapping(value = "/userList", method = RequestMethod.POST)
-	public Result userList(String mobile, String email,
+	public Result userList(String username, String mobile, String email,
 			@RequestParam(name = "createTime[]", required = false) String[] createTime, Integer number,
 			String aftUsername, Integer auditStatus, String pageNo, String pageSize) throws ParseException {
 		Result res = new Result();
@@ -442,7 +460,7 @@ public class AdminApiController extends CertifyApiController {
 		if (StringUtils.isNumeric(pageNo)) {
 			pNo = Integer.parseInt(pageNo);
 		}
-		res.setData(getUserList(mobile, email, createTime, number, aftUsername, auditStatus, pNo, pSize));
+		res.setData(getUserList(username, mobile, email, createTime, number, aftUsername, auditStatus, pNo, pSize));
 		return res;
 	}
 
@@ -2966,9 +2984,9 @@ public class AdminApiController extends CertifyApiController {
 	}
 
 	// user个人列表
-	private Pagination<UserListBo> getUserList(String mobile, String email, String[] createTime, Integer number,
-			String aftUsername, Integer auditStatus, Integer pNo, Integer pSize) throws ParseException {
-		return userService.listUser(mobile, email, createTime, number, aftUsername, auditStatus, pNo, pSize);
+	private Pagination<UserListBo> getUserList(String username, String mobile, String email, String[] createTime,
+			Integer number, String aftUsername, Integer auditStatus, Integer pNo, Integer pSize) throws ParseException {
+		return userService.listUser(username, mobile, email, createTime, number, aftUsername, auditStatus, pNo, pSize);
 	}
 
 	// 高企详情

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

@@ -1,11 +1,9 @@
 package com.goafanti.common.dao;
 
-import java.util.List;
 
 import org.apache.ibatis.annotations.Param;
 
 import com.goafanti.common.model.User;
-import com.goafanti.user.bo.OrgListBo;
 import com.goafanti.user.bo.OrgPartnerDetailBo;
 import com.goafanti.user.bo.UserDownLoadBo;
 import com.goafanti.user.bo.UserPageHomeBo;
@@ -30,7 +28,7 @@ public interface UserMapper {
 
 	UserDownLoadBo selectUserDownLoadBoByUserId(String id);
 
-	List<OrgListBo> selectUserByAid(String aid);
+	//List<OrgListBo> selectUserByAid(String aid);
 
 	String findUserByNameAndMobile(@Param("name") String name, @Param("mobile") String mobile);
 

+ 6 - 2
src/main/java/com/goafanti/common/mapper/OrgCognizanceMapper.xml

@@ -520,8 +520,12 @@
   </select>
   
   <select id="selectLatelyRecordYear" resultType="Integer" parameterType="java.lang.String" >
-  select Max(year)  from  org_cognizance  where state not in (8, 11, 13)
-	 and deleted_sign = 0 and uid= #{uid,jdbcType=VARCHAR} 
+     select 
+  		Max(year)  
+  	 from  org_cognizance  
+  	 where state not in (8, 11, 13)
+	 and deleted_sign = 0 
+	 and uid= #{uid,jdbcType=VARCHAR} 
 
   </select>
   

+ 193 - 23
src/main/java/com/goafanti/common/mapper/UserMapper.xml

@@ -216,9 +216,17 @@
   </select>
   
   <select id="findUserListByPage" parameterType="String" resultType="com.goafanti.user.bo.UserListBo">
-  	select u.id ,u.mobile, u.email, u.create_time as createTime, 
-  	       u.number , i.aft_username as aftUsername, i.audit_status as auditStatus, a.name as adminName,
-  	       ad.name as managerName
+  	select 
+  		u.id ,
+  		u.mobile, 
+  		u.email, 
+  		u.create_time as createTime, 
+  	    u.number , 
+  	    i.aft_username as aftUsername, 
+  	    i.username,
+  	    i.audit_status as auditStatus, 
+  	    a.name as adminName,
+  	    ad.name as managerName
     from user u  
     LEFT JOIN admin a on a.id = u.aid
     LEFT JOIN admin ad on ad.id = u.mid
@@ -272,7 +280,7 @@
 		and u.number = #{number,jdbcType=INTEGER}
 	</if>
 	<if test="username != null">
-		and i.username = #{username,jdbcType=VARCHAR}
+		and i.username like CONCAT('%', #{username,jdbcType=VARCHAR}, '%')   
 	</if>
 	<if test="auditStatus != null">
 		and i.audit_status= #{auditStatus,jdbcType=INTEGER}
@@ -351,19 +359,167 @@
 	</if>
   </select>  
   
-   <select id="selectUserByAid" parameterType="java.lang.String" resultType="com.goafanti.user.bo.OrgListBo">
-    select u.id ,u.mobile, u.email, u.create_time as createTime, 
-  	       u.number , o.aft_username as aftUsername, o.audit_status as orgAuditStatus, a.name as adminName, u.type,
-  	       o.unit_name as unitName, i.username, i.audit_status as userAuditStatus
+   <select id="findUserByAidWithParamsListByPage" parameterType="java.lang.String" resultType="com.goafanti.user.bo.OrgListBo">
+    select 
+    	u.id ,
+    	u.mobile, 
+    	u.email, 
+    	u.create_time as createTime, 
+  	    u.number , 
+  	    a.name as adminName, 
+  	    u.type,
+  	    i.username, 
+  	    i.audit_status as userAuditStatus,
+  	    i.aft_username as aftUsername
     from user u  
     LEFT JOIN admin a on a.id = u.aid 
-	LEFT JOIN organization_identity o  ON u.id = o.uid 
 	LEFT JOIN user_identity i on u.id = i.uid
-   
-    where u.aid = #{aid,jdbcType=VARCHAR}
+    where u.type = 0
+    <if test="aid != null">
+    	and u.aid = #{aid,jdbcType=VARCHAR}
+    </if>
+    <if test="number !=null">
+    	and u.number = #{number,jdbcType=INTEGER}
+    </if>
+    <if test="mobile !=null">
+    	and u.mobile= #{mobile,jdbcType=VARCHAR}
+    </if>
+    <if test="auditStatus !=null">
+    	and i.audit_status = #{auditStatus,jdbcType=INTEGER}
+    </if>
+     <if test="auditName !=null">
+    	and i.username like CONCAT('%', #{auditName,jdbcType=VARCHAR}, '%')
+    </if>
+    <if test="email !=null">
+    	and u.email = #{email,jdbcType=VARCHAR}
+    </if>
+    <if test="startCreateTime !=null">
+    	and u.create_time <![CDATA[ >= ]]> #{startCreateTime,jdbcType=TIMESTAMP}
+    </if>
+     <if test="endCreateTime !=null">
+    	and u.create_time <![CDATA[ < ]]> #{endCreateTime,jdbcType=TIMESTAMP}
+    </if>
+    order by u.number desc
+    <if test="page_sql!=null">
+		${page_sql}
+	</if>
+  </select>
+  
+  <select id="findUserByAidWithParamsCount" parameterType="String" resultType="java.lang.Integer">
+  	 select 
+    	count(1)
+    from user u  
+    LEFT JOIN admin a on a.id = u.aid 
+	LEFT JOIN user_identity i on u.id = i.uid
+    where u.type = 0
+    <if test="aid != null">
+    	and u.aid = #{aid,jdbcType=VARCHAR}
+    </if>
+    <if test="number !=null">
+    	and u.number = #{number,jdbcType=INTEGER}
+    </if>
+    <if test="mobile !=null">
+    	and u.mobile= #{mobile,jdbcType=VARCHAR}
+    </if>
+    <if test="auditStatus !=null">
+    	and i.audit_status = #{auditStatus,jdbcType=INTEGER}
+    </if>
+    <if test="auditName !=null">
+    	and i.username like CONCAT('%', #{auditName,jdbcType=VARCHAR}, '%')
+    </if>
+    <if test="email !=null">
+    	and u.email = #{email,jdbcType=VARCHAR}
+    </if>
+    <if test="startCreateTime !=null">
+    	and u.create_time <![CDATA[ >= ]]> #{startCreateTime,jdbcType=TIMESTAMP}
+    </if>
+     <if test="endCreateTime !=null">
+    	and u.create_time <![CDATA[ < ]]> #{endCreateTime,jdbcType=TIMESTAMP}
+    </if>
+  </select>
+  
+  
+  <select id="findOrgByAidWithParamsListByPage" parameterType="java.lang.String" resultType="com.goafanti.user.bo.OrgListBo">
+    select 
+    	u.id ,
+    	u.mobile, 
+    	u.email, 
+    	u.create_time as createTime, 
+  	    u.number , 
+  	    a.name as adminName, 
+  	    u.type,
+  	    i.unit_name as unitName, 
+  	    i.audit_status as orgAuditStatus,
+  	    i.aft_username as aftUsername
+    from user u  
+    LEFT JOIN admin a on a.id = u.aid 
+	LEFT JOIN organization_identity i on u.id = i.uid
+    where u.type = 1
+    <if test="aid != null">
+    	and u.aid = #{aid,jdbcType=VARCHAR}
+    </if>
+    <if test="number !=null">
+    	and u.number = #{number,jdbcType=INTEGER}
+    </if>
+    <if test="mobile !=null">
+    	and u.mobile= #{mobile,jdbcType=VARCHAR}
+    </if>
+    <if test="auditStatus !=null">
+    	and i.audit_status = #{auditStatus,jdbcType=INTEGER}
+    </if>
+     <if test="auditName !=null">
+    	and i.username like CONCAT('%', #{auditName,jdbcType=VARCHAR}, '%')
+    </if>
+    <if test="email !=null">
+    	and u.email = #{email,jdbcType=VARCHAR}
+    </if>
+    <if test="startCreateTime !=null">
+    	and u.create_time <![CDATA[ >= ]]> #{startCreateTime,jdbcType=TIMESTAMP}
+    </if>
+    <if test="endCreateTime !=null">
+    	and u.create_time <![CDATA[ < ]]> #{endCreateTime,jdbcType=TIMESTAMP}
+    </if>
     order by u.number desc
+    <if test="page_sql!=null">
+		${page_sql}
+	</if>
   </select>
   
+  <select id="findOrgByAidWithParamsCount" parameterType="String" resultType="java.lang.Integer">
+  	 select 
+    	count(1)
+    from user u  
+    LEFT JOIN admin a on a.id = u.aid 
+	LEFT JOIN organization_identity i on u.id = i.uid
+    where u.type = 1
+    <if test="aid != null">
+    	and u.aid = #{aid,jdbcType=VARCHAR}
+    </if>
+    <if test="number !=null">
+    	and u.number = #{number,jdbcType=INTEGER}
+    </if>
+    <if test="mobile !=null">
+    	and u.mobile= #{mobile,jdbcType=VARCHAR}
+    </if>
+    <if test="auditStatus !=null">
+    	and i.audit_status = #{auditStatus,jdbcType=INTEGER}
+    </if>
+    <if test="auditName !=null">
+    	and i.unit_name like CONCAT('%', #{auditName,jdbcType=VARCHAR}, '%')
+    </if>
+    <if test="email !=null">
+    	and u.email = #{email,jdbcType=VARCHAR}
+    </if>
+    <if test="startCreateTime !=null">
+    	and u.create_time <![CDATA[ >= ]]> #{startCreateTime,jdbcType=TIMESTAMP}
+    </if>
+     <if test="endCreateTime !=null">
+    	and u.create_time <![CDATA[ < ]]> #{endCreateTime,jdbcType=TIMESTAMP}
+    </if>
+  </select>
+  
+  
+  
   <select id="findUserByNameAndMobile" resultType="java.lang.String">
   	select 
   		ui.username
@@ -393,14 +549,22 @@
   </select>
   
    <select id="findAreaManagerUserListByPage" parameterType="String" resultType="com.goafanti.user.bo.UserListBo">
-  	select u.id ,u.mobile, u.email, u.create_time as createTime, 
-  	       u.number , i.aft_username as aftUsername, i.audit_status as auditStatus, a.name as adminName,
-  	       ad.name as managerName
+  	select 
+  		u.id ,
+  		u.mobile, 
+  		u.email, 
+  		u.create_time as createTime, 
+  	    u.number , 
+  	    i.aft_username as aftUsername, 
+  	    i.audit_status as auditStatus, 
+  	    i.username,
+  	    a.name as adminName,
+  	    ad.name as managerName
     from user u  
     LEFT JOIN admin a on a.id = u.aid
     LEFT JOIN admin ad on ad.id = u.mid
-    LEFT JOIN user_identity i 
-    ON u.id = i.uid  where u.type = 0
+    LEFT JOIN user_identity i on u.id = i.uid  
+    where u.type = 0
     <if test = "mobile != null">
 	    and u.mobile = #{mobile,jdbcType=VARCHAR}
 	</if>
@@ -463,7 +627,7 @@
 		and u.number = #{number,jdbcType=INTEGER}
 	</if>
 	<if test="username != null">
-		and i.username = #{username,jdbcType=VARCHAR}
+		and i.username like CONCAT('%', #{username,jdbcType=VARCHAR}, '%')   
 	</if>
 	<if test="auditStatus != null">
 		and i.audit_status= #{auditStatus,jdbcType=INTEGER}
@@ -484,16 +648,22 @@
   </select>  
   
    <select id="findAreaManagerOrgListByPage" parameterType="String" resultType="com.goafanti.user.bo.OrgListBo">
-  select u.id ,u.mobile, u.email, u.create_time as createTime, 
-  	       u.number , o.aft_username as aftUsername, o.audit_status as auditStatus, a.name as adminName,
-  	       o.unit_name as unitName, ad.name as managerName
+  	select 
+  		u.id ,
+  		u.mobile, 
+  		u.email, 
+  		u.create_time as createTime, 
+  	    u.number , 
+  	    o.aft_username as aftUsername, 
+  	    o.audit_status as auditStatus, 
+  	    a.name as adminName,
+  	    o.unit_name as unitName, 
+  	    ad.name as managerName
     from user u  
     LEFT JOIN admin a on a.id = u.aid 
     LEFT JOIN admin ad on ad.id = u.mid
-	LEFT JOIN organization_identity o 
-    ON u.id = o.uid 
+	LEFT JOIN organization_identity o on u.id = o.uid 
     WHERE u.type = 1
-   
     <if test = "mobile != null">
 	    and u.mobile = #{mobile,jdbcType=VARCHAR}
 	</if>

+ 10 - 0
src/main/java/com/goafanti/user/bo/UserListBo.java

@@ -28,6 +28,16 @@ public class UserListBo {
 
 	private String	managerName;
 
+	private String	username;
+	
+	public String getUsername() {
+		return username;
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+
 	public String getId() {
 		return id;
 	}

+ 5 - 4
src/main/java/com/goafanti/user/service/UserService.java

@@ -32,13 +32,14 @@ public interface UserService {
 
 	UserDownLoadBo selectUserDownLoadBoByUserId(String userId);
 
-	Pagination<UserListBo> listUser(String mobile, String email, String[] createTime, Integer number,
+	Pagination<UserListBo> listUser(String username, String mobile, String email, String[] createTime, Integer number,
 			String aftUsername, Integer auditStatus, Integer pNo, Integer pSize) throws ParseException;
 
-	Pagination<OrgListBo> listOrg(String uid, String mobile, String email, String[] createTime, Integer number, String unitName,
-			Integer auditStatus, Integer pNo, Integer pSize) throws ParseException;
+	Pagination<OrgListBo> listOrg(String uid, String mobile, String email, String[] createTime, Integer number,
+			String unitName, Integer auditStatus, Integer pNo, Integer pSize) throws ParseException;
 
-	List<OrgListBo> selectUserByAid(String adminId);
+	Pagination<OrgListBo> selectUserByAid(Integer number, String mobile, Integer auditStatus, String auditName, String email,
+			String adminId, String startCreateTime, String endCreateTime, Integer type, Integer pNo, Integer pSize);
 
 	List<OrgUnitNames> selectDemandUnitNames();
 

+ 67 - 4
src/main/java/com/goafanti/user/service/impl/UserServiceImpl.java

@@ -135,8 +135,8 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 
 	@SuppressWarnings("unchecked")
 	@Override
-	public Pagination<UserListBo> listUser(String mobile, String email, String[] pDate, Integer number, String username,
-			Integer auditStatus, Integer pageNo, Integer pageSize) throws ParseException {
+	public Pagination<UserListBo> listUser(String username, String mobile, String email, String[] pDate, Integer number,
+			String aftUsername, Integer auditStatus, Integer pageNo, Integer pageSize) throws ParseException {
 		Map<String, Object> params = new HashMap<>();
 		Date pStart = null;
 		Date pEnd = null;
@@ -176,6 +176,10 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 			params.put("auditStatus", auditStatus);
 		}
 
+		if (!StringUtils.isBlank(username)) {
+			params.put("username", username);
+		}
+
 		if (pageNo == null || pageNo < 0) {
 			pageNo = 1;
 		}
@@ -271,9 +275,68 @@ public class UserServiceImpl extends BaseMybatisDao<UserMapper> implements UserS
 		return null;
 	}
 
+	@SuppressWarnings("unchecked")
 	@Override
-	public List<OrgListBo> selectUserByAid(String aid) {
-		return userMapper.selectUserByAid(aid);
+	public Pagination<OrgListBo> selectUserByAid(Integer number, String mobile, Integer auditStatus, String auditName,
+			String email, String aid, String startCreateTime, String endCreateTime, Integer type, Integer pageNo,
+			Integer pageSize) {
+		Map<String, Object> params = new HashMap<>();
+
+		if (StringUtils.isNotBlank(startCreateTime)) {
+			try {
+				params.put("startCreateTime", DateUtils.parseDate(startCreateTime, AFTConstants.YYYYMMDD));
+			} catch (ParseException e) {
+			}
+		}
+
+		if (StringUtils.isNotBlank(endCreateTime)) {
+			try {
+				params.put("endCreateTime",
+						DateUtils.addDays(DateUtils.parseDate(endCreateTime, AFTConstants.YYYYMMDD), 1));
+			} catch (ParseException e) {
+			}
+		}
+
+		if (null != number) {
+			params.put("number", number);
+		}
+
+		if (StringUtils.isNotBlank(mobile)) {
+			params.put("mobile", mobile);
+		}
+
+		if (null != auditStatus) {
+			params.put("auditStatus", auditStatus);
+		}
+
+		if (StringUtils.isNotBlank(auditName)) {
+			params.put("auditName", auditName);
+		}
+
+		if (StringUtils.isNotBlank(email)) {
+			params.put("email", email);
+		}
+
+		if (!TokenManager.hasRole(AFTConstants.SUPERADMIN)) {
+			params.put("aid", aid);
+		}
+
+		if (pageNo == null || pageNo < 0) {
+			pageNo = 1;
+		}
+
+		if (pageSize == null || pageSize < 0 || pageSize > 10) {
+			pageSize = 10;
+		}
+
+		if (UserType.PERSONAL.getCode().equals(type)) {
+			return (Pagination<OrgListBo>) findPage("findUserByAidWithParamsListByPage", "findUserByAidWithParamsCount",
+					params, pageNo, pageSize);
+		} else if (UserType.ORGANIZATION.getCode().equals(type)) {
+			return (Pagination<OrgListBo>) findPage("findOrgByAidWithParamsListByPage", "findOrgByAidWithParamsCount",
+					params, pageNo, pageSize);
+		}
+		return null;
 	}
 
 	@Override