Commit 0ef4f21a authored by libin's avatar libin

客服功能

parent 25becb30
......@@ -15,6 +15,8 @@ import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
......@@ -88,10 +90,19 @@ public class CustomerServiceBiz {
customerServiceRepository.save(customerService);
}
/**
* 1: mongoTemplate.find(Query.query(Criteria.where("isDel").is(false)), CustomerService.class);
*
* 2. customerServiceRepository.findByIsDelEquals(false);
* @return
*/
public List<CustomerServiceVO> findAll() {
List<CustomerServiceVO> customerServiceVOS = new ArrayList<>();
// List<CustomerService> customerServices = mongoTemplate.find(Query.query(Criteria.where("isDel").is(false)), CustomerService.class);
List<CustomerService> customerServices = customerServiceRepository.findByIsDelEquals(false);
CustomerService customer_service = new CustomerService();
Example<CustomerService> customerServiceExample = Example.of(customer_service, ExampleMatcher.matchingAll());
List<CustomerService> customerServices = customerServiceRepository.findAll(customerServiceExample);
CustomerServiceVO customerServiceVO;
if (CollectionUtils.isNotEmpty(customerServices)){
List<Integer> imUserIds = customerServices.stream().map(CustomerService::getImUserId).collect(Collectors.toList());
......@@ -117,7 +128,7 @@ public class CustomerServiceBiz {
public void updateCustomerServiceIsDelToTrue(String id,Integer imUserId){
Query query = query(Criteria.where("_id").is(id));
Update update = update("is_del", true).set("update_time",Instant.now().toEpochMilli());
UpdateResult customer_service = mongoTemplate.updateFirst(query, update, Map.class, "customer_service");
mongoTemplate.updateFirst(query, update, Map.class, "customer_service");
userBiz.deleteById(imUserId);
}
}
......@@ -2,6 +2,8 @@ package com.xxfc.platform.im.repos;
import com.xxfc.platform.im.model.CustomerService;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.mongodb.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
......@@ -17,10 +19,13 @@ public interface CustomerServiceRepository extends MongoRepository<CustomerServi
/**
* 查询客服
* @param isDel 删除状态
* * @param isDel 删除状态
* @return
*/
List<CustomerService> findByIsDelEquals(Boolean isDel);
List<CustomerService> findByIsDel(Boolean isDel);
// @Query(value = "{'is_del':?0}",fields ="{'telphone':1}",sort = "{'create_time':-1}")
@Query(value = "{'is_del':?#{[0]}}",fields ="{'name':1}",sort = "{'create_time':-1}")
List<CustomerService> findByIsDelState(Boolean isDel);
}
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