Commit 3294a9d0 authored by lee_mingzhu's avatar lee_mingzhu

添加客服根据条件查询用户详情的相关方法

parent 34c33f50
...@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.ParseException; import java.text.ParseException;
import java.util.List;
/** /**
* Created by Miraculous on 2016/12/19. * Created by Miraculous on 2016/12/19.
...@@ -187,4 +188,10 @@ public class InnerController { ...@@ -187,4 +188,10 @@ public class InnerController {
return JsonResult.buildSuccessResult(null, null); return JsonResult.buildSuccessResult(null, null);
} }
@RequestMapping("/user_detail/search_list")
public JsonResult searchUserDetailList(String name, String phoneNo, String idNo) {
List<UserDetail> userDetails = userDetailService.searchUserDetailList(name, phoneNo, idNo);
return JsonResult.buildSuccessResult("success", userDetails);
}
} }
\ No newline at end of file
package cn.quantgroup.xyqb.repository; package cn.quantgroup.xyqb.repository;
import cn.quantgroup.xyqb.entity.UserDetail; import cn.quantgroup.xyqb.entity.UserDetail;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* @author mengfan.feng * @author mengfan.feng
* @time 2015-09-11 11:22 * @time 2015-09-11 11:22
...@@ -21,4 +24,6 @@ public interface IUserDetailRepository extends JpaRepository<UserDetail, Long> { ...@@ -21,4 +24,6 @@ public interface IUserDetailRepository extends JpaRepository<UserDetail, Long> {
@Query(value = "update user_detail set qq = ?1 where user_id = ?2", nativeQuery = true) @Query(value = "update user_detail set qq = ?1 where user_id = ?2", nativeQuery = true)
void updateUserQQ(String qq, Long userId); void updateUserQQ(String qq, Long userId);
List<UserDetail> findAll(Specification<UserDetail> specification);
} }
...@@ -2,6 +2,8 @@ package cn.quantgroup.xyqb.service.user; ...@@ -2,6 +2,8 @@ package cn.quantgroup.xyqb.service.user;
import cn.quantgroup.xyqb.entity.UserDetail; import cn.quantgroup.xyqb.entity.UserDetail;
import java.util.List;
/** /**
* Created by 11 on 2016/12/29. * Created by 11 on 2016/12/29.
*/ */
...@@ -13,4 +15,6 @@ public interface IUserDetailService { ...@@ -13,4 +15,6 @@ public interface IUserDetailService {
UserDetail findByPhoneNo(String phoneNo); UserDetail findByPhoneNo(String phoneNo);
void updateUserQQ(Long userId, String qq); void updateUserQQ(Long userId, String qq);
List<UserDetail> searchUserDetailList(String name, String phoneNo, String idNo);
} }
...@@ -3,9 +3,14 @@ package cn.quantgroup.xyqb.service.user.impl; ...@@ -3,9 +3,14 @@ package cn.quantgroup.xyqb.service.user.impl;
import cn.quantgroup.xyqb.entity.UserDetail; import cn.quantgroup.xyqb.entity.UserDetail;
import cn.quantgroup.xyqb.repository.IUserDetailRepository; import cn.quantgroup.xyqb.repository.IUserDetailRepository;
import cn.quantgroup.xyqb.service.user.IUserDetailService; import cn.quantgroup.xyqb.service.user.IUserDetailService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.persistence.criteria.*;
import java.util.List;
/** /**
* Created by 11 on 2016/12/29. * Created by 11 on 2016/12/29.
*/ */
...@@ -34,4 +39,31 @@ public class UserDetailServiceImpl implements IUserDetailService { ...@@ -34,4 +39,31 @@ public class UserDetailServiceImpl implements IUserDetailService {
public void updateUserQQ(Long userId, String qq) { public void updateUserQQ(Long userId, String qq) {
userDetailRepository.updateUserQQ(qq, userId); userDetailRepository.updateUserQQ(qq, userId);
} }
@Override
public List<UserDetail> searchUserDetailList(String name, String phoneNo, String idNo) {
return userDetailRepository.findAll(getSpecification(name, phoneNo, idNo));
}
private Specification<UserDetail> getSpecification(String name, String phoneNo, String idNo) {
Specification<UserDetail> specification = new Specification<UserDetail>() {
@Override
public Predicate toPredicate(Root<UserDetail> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
if (!StringUtils.isEmpty(name)) {
Path<String> namePath = root.get("name");
criteriaQuery.where(criteriaBuilder.equal(namePath, name));
}
if (!StringUtils.isEmpty(phoneNo)) {
Path<String> phonePath = root.get("phoneNo");
criteriaQuery.where(criteriaBuilder.equal(phonePath, phoneNo));
}
if (!StringUtils.isEmpty(idNo)) {
Path<String> idNoPath = root.get("idNo");
criteriaQuery.where(criteriaBuilder.equal(idNoPath, idNo));
}
return null;
}
};
return specification;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment