mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
Fix ContactsRepository related class
This commit is contained in:
parent
ad6946e859
commit
ce30bca698
@ -30,56 +30,55 @@ import com.chatopera.cc.proxy.AgentStatusProxy;
|
||||
import com.chatopera.cc.proxy.AgentUserProxy;
|
||||
import com.chatopera.compose4j.Functional;
|
||||
import com.chatopera.compose4j.Middleware;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Resolve AgentUser
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class ACDVisBodyParserMw implements Middleware<ACDComposeContext> {
|
||||
private final static Logger logger = LoggerFactory.getLogger(ACDVisBodyParserMw.class);
|
||||
|
||||
@Autowired
|
||||
private AgentUserContactsRepository agentUserContactsRes;
|
||||
@NonNull
|
||||
private final AgentUserContactsRepository agentUserContactsRes;
|
||||
|
||||
@Autowired
|
||||
private ContactsRepository contactsRes;
|
||||
@NonNull
|
||||
private final ContactsRepository contactsRes;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
@NonNull
|
||||
private final Cache cache;
|
||||
|
||||
@Autowired
|
||||
private AgentUserProxy agentUserProxy;
|
||||
@NonNull
|
||||
private final AgentUserProxy agentUserProxy;
|
||||
|
||||
@Autowired
|
||||
private AgentStatusProxy agentStatusProxy;
|
||||
@NonNull
|
||||
private final AgentStatusProxy agentStatusProxy;
|
||||
|
||||
@Autowired
|
||||
private ACDQueueService acdQueueService;
|
||||
@NonNull
|
||||
private final ACDQueueService acdQueueService;
|
||||
|
||||
@Autowired
|
||||
private ACDMessageHelper acdMessageHelper;
|
||||
@NonNull
|
||||
private final ACDMessageHelper acdMessageHelper;
|
||||
|
||||
/**
|
||||
* 设置AgentUser基本信息
|
||||
*
|
||||
* @param ctx
|
||||
* @param next
|
||||
*/
|
||||
@Override
|
||||
public void apply(final ACDComposeContext ctx, final Functional next) {
|
||||
|
||||
/**
|
||||
/*
|
||||
* NOTE AgentUser代表一次会话记录,在上一个会话结束,并且由坐席人员点击"清除"后,会从数据库中删除
|
||||
* 此处查询到的,可能是之前的会话。其状态需要验证,所以不一定是由TA来服务本次会话。
|
||||
*/
|
||||
AgentUser agentUser = cache.findOneAgentUserByUserIdAndOrgi(ctx.getOnlineUserId(), ctx.getOrgi()).orElseGet(
|
||||
() -> {
|
||||
/**
|
||||
/*
|
||||
* NOTE 新创建的AgentUser不需要设置Status和Agentno
|
||||
* 因为两个值在后面会检查,如果存在则不会申请新的Agent
|
||||
*/
|
||||
@ -125,11 +124,11 @@ public class ACDVisBodyParserMw implements Middleware<ACDComposeContext> {
|
||||
|
||||
next.apply();
|
||||
|
||||
/**
|
||||
/*
|
||||
* 发送通知
|
||||
*/
|
||||
if (ctx.getAgentService() != null && StringUtils.isNotBlank(ctx.getAgentService().getStatus())) {
|
||||
/**
|
||||
/*
|
||||
* 找到空闲坐席,如果未找到坐席,则将该用户放入到 排队队列
|
||||
*/
|
||||
switch (MainContext.AgentUserStatusEnum.toValue(ctx.getAgentService().getStatus())) {
|
||||
@ -150,9 +149,7 @@ public class ACDVisBodyParserMw implements Middleware<ACDComposeContext> {
|
||||
ctx.getAgentService().getQueneindex());
|
||||
|
||||
if (StringUtils.isNotBlank(ctx.getAgentService().getAgentuserid())) {
|
||||
agentUserProxy.findOne(ctx.getAgentService().getAgentuserid()).ifPresent(p -> {
|
||||
ctx.setAgentUser(p);
|
||||
});
|
||||
agentUserProxy.findOne(ctx.getAgentService().getAgentuserid()).ifPresent(ctx::setAgentUser);
|
||||
}
|
||||
|
||||
// TODO 如果是 INSERVICE 那么 agentService.getAgentuserid 就一定不能为空?
|
||||
@ -219,10 +216,6 @@ public class ACDVisBodyParserMw implements Middleware<ACDComposeContext> {
|
||||
* <p>
|
||||
* TODO 此处有一些问题:如果联系人更新了名字,那么么后面TA的会话用的还是旧的名字,
|
||||
* 所以,在更新联系人名字的时候,也应更新其对应的AgentUser里面的名字
|
||||
*
|
||||
* @param agentUser
|
||||
* @param nickname
|
||||
* @return
|
||||
*/
|
||||
private String resolveAgentUsername(final AgentUser agentUser, final String nickname) {
|
||||
if (!StringUtils.equals(agentUser.getUsername(), nickname)) {
|
||||
@ -233,7 +226,7 @@ public class ACDVisBodyParserMw implements Middleware<ACDComposeContext> {
|
||||
AgentUserContacts agentUserContact = agentUserContactsRes.findOneByUseridAndOrgi(
|
||||
agentUser.getUserid(), agentUser.getOrgi()).orElse(null);
|
||||
if (agentUserContact != null) {
|
||||
Contacts contact = contactsRes.findOneById(agentUserContact.getContactsid()).orElseGet(null);
|
||||
Contacts contact = contactsRes.findOneById(agentUserContact.getContactsid()).orElse(null);
|
||||
if (contact != null) {
|
||||
return contact.getName();
|
||||
}
|
||||
|
@ -32,15 +32,15 @@ import com.chatopera.cc.util.RestResultType;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@ -56,40 +56,35 @@ import java.util.Optional;
|
||||
* 联系人服务
|
||||
* 联系人管理功能
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/api/contacts")
|
||||
@RequiredArgsConstructor
|
||||
public class ApiContactsController extends Handler {
|
||||
private final static Logger logger = LoggerFactory.getLogger(ApiContactsController.class);
|
||||
|
||||
@Autowired
|
||||
private ContactsRepository contactsRepository;
|
||||
@NonNull
|
||||
private final ContactsRepository contactsRepository;
|
||||
|
||||
@Autowired
|
||||
private ContactsRepository contactsRes;
|
||||
@NonNull
|
||||
private final ContactsProxy contactsProxy;
|
||||
|
||||
@Autowired
|
||||
private ContactsProxy contactsProxy;
|
||||
|
||||
@Autowired
|
||||
private AgentUserProxy agentUserProxy;
|
||||
@NonNull
|
||||
private final AgentUserProxy agentUserProxy;
|
||||
|
||||
/**
|
||||
* 返回用户列表,支持分页,分页参数为 p=1&ps=50,默认分页尺寸为 20条每页
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@Menu(type = "apps", subtype = "contacts", access = true)
|
||||
public ResponseEntity<RestResult> list(HttpServletRequest request, @Valid String creater, @Valid String q) {
|
||||
Page<Contacts> contactsList = null;
|
||||
Page<Contacts> contactsList;
|
||||
if (!StringUtils.isBlank(creater)) {
|
||||
User user = super.getUser(request);
|
||||
contactsList = contactsRepository.findByCreaterAndSharesAndOrgi(user.getId(), user.getId(),
|
||||
super.getOrgi(request), false, q,
|
||||
PageRequest.of(
|
||||
super.getP(request),
|
||||
super.getPs(request)));
|
||||
super.getOrgi(request), false, q,
|
||||
PageRequest.of(
|
||||
super.getP(request),
|
||||
super.getPs(request)));
|
||||
} else {
|
||||
contactsList = contactsRepository.findByOrgi(super.getOrgi(request), false, q,
|
||||
PageRequest.of(super.getP(request), super.getPs(request)));
|
||||
@ -99,9 +94,6 @@ public class ApiContactsController extends Handler {
|
||||
|
||||
/**
|
||||
* 新增或修改用户用户 ,在修改用户信息的时候,如果用户 密码未改变,请设置为 NULL
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.PUT)
|
||||
@Menu(type = "apps", subtype = "contacts", access = true)
|
||||
@ -122,43 +114,34 @@ public class ApiContactsController extends Handler {
|
||||
/**
|
||||
* 删除用户,只提供 按照用户ID删除 , 并且,不能删除系统管理员
|
||||
* 删除联系人,联系人删除是逻辑删除,将 datastatus字段标记为 true,即已删除
|
||||
*
|
||||
* @param request
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.DELETE)
|
||||
@Menu(type = "apps", subtype = "contacts", access = true)
|
||||
public ResponseEntity<RestResult> delete(HttpServletRequest request, @Valid String id) {
|
||||
public ResponseEntity<RestResult> delete(@Valid String id) {
|
||||
RestResult result = new RestResult(RestResultType.OK);
|
||||
if (!StringUtils.isBlank(id)) {
|
||||
Contacts contacts = contactsRepository.findOne(id);
|
||||
if (contacts != null) { //系统管理员, 不允许 使用 接口删除
|
||||
contactsRepository.findById(id).ifPresent(contacts -> {
|
||||
//系统管理员, 不允许 使用 接口删除
|
||||
contacts.setDatastatus(true);
|
||||
contactsRepository.save(contacts);
|
||||
}
|
||||
});
|
||||
}
|
||||
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 联系人页面,客户点击页面时,判断是否有能触达的通道
|
||||
*
|
||||
* @param request
|
||||
* @param body
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
@Menu(type = "apps", subtype = "contacts", access = true)
|
||||
public ResponseEntity<String> operations(
|
||||
final HttpServletRequest request,
|
||||
@RequestBody final String body) {
|
||||
final JsonObject j = (new JsonParser()).parse(body).getAsJsonObject();
|
||||
logger.info("[chatbot] operations payload {}", j.toString());
|
||||
final JsonObject j = JsonParser.parseString(body).getAsJsonObject();
|
||||
log.info("[chatbot] operations payload {}", j.toString());
|
||||
JsonObject json = new JsonObject();
|
||||
HttpHeaders headers = RestUtils.header();
|
||||
final User logined = super.getUser(request);
|
||||
final String orgi = logined.getOrgi();
|
||||
|
||||
if (!j.has("ops")) {
|
||||
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_1);
|
||||
@ -179,15 +162,11 @@ public class ApiContactsController extends Handler {
|
||||
}
|
||||
}
|
||||
|
||||
return new ResponseEntity<String>(json.toString(), headers, HttpStatus.OK);
|
||||
return new ResponseEntity<>(json.toString(), headers, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 主动与联系人聊天
|
||||
*
|
||||
* @param payload
|
||||
* @param logined
|
||||
* @return
|
||||
*/
|
||||
private JsonObject proactive(final JsonObject payload, User logined) {
|
||||
JsonObject resp = new JsonObject();
|
||||
@ -218,10 +197,6 @@ public class ApiContactsController extends Handler {
|
||||
|
||||
/**
|
||||
* 根据联系人信息查找立即触达的渠道
|
||||
*
|
||||
* @param payload
|
||||
* @param logined
|
||||
* @return
|
||||
*/
|
||||
private JsonObject approach(final JsonObject payload, final User logined) {
|
||||
JsonObject resp = new JsonObject();
|
||||
@ -233,7 +208,7 @@ public class ApiContactsController extends Handler {
|
||||
}
|
||||
|
||||
final String contactsid = payload.get("contactsid").getAsString();
|
||||
Optional<Contacts> contactOpt = contactsRes.findOneById(contactsid).filter(
|
||||
Optional<Contacts> contactOpt = contactsRepository.findOneById(contactsid).filter(
|
||||
p -> !p.isDatastatus());
|
||||
|
||||
if (contactOpt.isPresent()) {
|
||||
|
@ -28,15 +28,16 @@ import com.chatopera.cc.util.RestResult;
|
||||
import com.chatopera.cc.util.RestResultType;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@ -54,24 +55,20 @@ import java.util.Date;
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/wl/contacts")
|
||||
@RequiredArgsConstructor
|
||||
public class ApiWlContactsController extends Handler {
|
||||
final private static Logger logger = LoggerFactory.getLogger(ApiWlContactsController.class);
|
||||
|
||||
@Autowired
|
||||
private ContactsRepository contactsRes;
|
||||
@NonNull
|
||||
private final ContactsRepository contactsRes;
|
||||
|
||||
/**
|
||||
* 返回联系人列表,支持分页,分页参数为 p=1&ps=50,默认分页尺寸为 20条每页
|
||||
*
|
||||
* @param request
|
||||
* @param creater
|
||||
* @param q
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@Menu(type = "apps", subtype = "contacts", access = true)
|
||||
public ResponseEntity<RestResult> list(HttpServletRequest request, @Valid String creater, @Valid String q) {
|
||||
Page<Contacts> contactsList = null;
|
||||
Page<Contacts> contactsList;
|
||||
if (StringUtils.isNotBlank(creater)) {
|
||||
User user = super.getUser(request);
|
||||
contactsList = contactsRes.findByCreaterAndSharesAndOrgi(
|
||||
@ -88,15 +85,11 @@ public class ApiWlContactsController extends Handler {
|
||||
|
||||
/**
|
||||
* 联系人
|
||||
*
|
||||
* @param request
|
||||
* @param body
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.POST)
|
||||
@Menu(type = "apps", subtype = "contacts", access = true)
|
||||
public ResponseEntity<String> operations(HttpServletRequest request, @RequestBody final String body) {
|
||||
final JsonObject j = (new JsonParser()).parse(body).getAsJsonObject();
|
||||
final JsonObject j = JsonParser.parseString(body).getAsJsonObject();
|
||||
logger.info("[wl/contacts api] operations payload {}", j.toString());
|
||||
JsonObject result = new JsonObject();
|
||||
HttpHeaders headers = RestUtils.header();
|
||||
@ -106,25 +99,18 @@ public class ApiWlContactsController extends Handler {
|
||||
result.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_1);
|
||||
result.addProperty(RestUtils.RESP_KEY_ERROR, "不合法的请求参数。");
|
||||
} else {
|
||||
switch (StringUtils.lowerCase(j.get("ops").getAsString())) {
|
||||
case "create": // 增加联系人类型
|
||||
result = createContact(logined.getId(), logined.getOrgi(), j);
|
||||
break;
|
||||
default:
|
||||
logger.info("[wl/contacts api] unknown operation {}", j.toString());
|
||||
if ("create".equals(StringUtils.lowerCase(j.get("ops").getAsString()))) { // 增加联系人类型
|
||||
result = createContact(logined.getId(), logined.getOrgi(), j);
|
||||
} else {
|
||||
logger.info("[wl/contacts api] unknown operation {}", j.toString());
|
||||
}
|
||||
}
|
||||
return new ResponseEntity<String>(result.toString(), headers, HttpStatus.OK);
|
||||
return new ResponseEntity<>(result.toString(), headers, HttpStatus.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建/更新联系人
|
||||
* 通过UID和SID和CID唯一确定一个联系人
|
||||
*
|
||||
* @param creator
|
||||
* @param orgi
|
||||
* @param j
|
||||
* @return
|
||||
*/
|
||||
private JsonObject createContact(
|
||||
final String creator,
|
||||
|
@ -29,13 +29,13 @@ import com.chatopera.cc.persistence.repository.UserEventRepository;
|
||||
import com.chatopera.cc.persistence.repository.UserRepository;
|
||||
import com.chatopera.cc.proxy.UserProxy;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -46,34 +46,36 @@ import javax.validation.Valid;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
public class AppsController extends Handler {
|
||||
private final static Logger logger = LoggerFactory.getLogger(AppsController.class);
|
||||
|
||||
@Autowired
|
||||
private ACDWorkMonitor acdWorkMonitor;
|
||||
@NonNull
|
||||
private final ACDWorkMonitor acdWorkMonitor;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRes;
|
||||
@NonNull
|
||||
private final UserRepository userRes;
|
||||
|
||||
@Autowired
|
||||
private OnlineUserRepository onlineUserRes;
|
||||
@NonNull
|
||||
private final OnlineUserRepository onlineUserRes;
|
||||
|
||||
@Autowired
|
||||
private UserEventRepository userEventRes;
|
||||
@NonNull
|
||||
private final UserEventRepository userEventRes;
|
||||
|
||||
@Autowired
|
||||
private ContactsRepository contactsRes;
|
||||
@NonNull
|
||||
private final ContactsRepository contactsRes;
|
||||
|
||||
@Autowired
|
||||
private OrgiSkillRelRepository orgiSkillRelService;
|
||||
@NonNull
|
||||
private final OrgiSkillRelRepository orgiSkillRelService;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
@NonNull
|
||||
private final Cache cache;
|
||||
|
||||
@Autowired
|
||||
private UserProxy userProxy;
|
||||
@NonNull
|
||||
private final UserProxy userProxy;
|
||||
|
||||
@RequestMapping({"/apps/content"})
|
||||
@Menu(type = "apps", subtype = "content")
|
||||
@ -81,9 +83,9 @@ public class AppsController extends Handler {
|
||||
final User user = super.getUser(request);
|
||||
final String orgi = super.getOrgi(request);
|
||||
|
||||
/****************************
|
||||
* 获得在线访客列表
|
||||
****************************/
|
||||
// ****************************
|
||||
// * 获得在线访客列表
|
||||
// ****************************
|
||||
|
||||
// TODO 此处为从数据库加载
|
||||
final Page<OnlineUser> onlineUserList = onlineUserRes.findByOrgiAndStatus(
|
||||
@ -98,9 +100,9 @@ public class AppsController extends Handler {
|
||||
);
|
||||
|
||||
final long msec = System.currentTimeMillis();
|
||||
final List<String> contactIds = new ArrayList<String>();
|
||||
final List<String> contactIds = new ArrayList<>();
|
||||
|
||||
/**
|
||||
/*
|
||||
* 设置访客状态
|
||||
*
|
||||
*/
|
||||
@ -111,11 +113,11 @@ public class AppsController extends Handler {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* 获得在线访客与联系人的关联信息
|
||||
*/
|
||||
if (contactIds.size() > 0) {
|
||||
final Iterable<Contacts> contacts = contactsRes.findAll(contactIds);
|
||||
final Iterable<Contacts> contacts = contactsRes.findAllById(contactIds);
|
||||
for (final OnlineUser onlineUser : onlineUserList.getContent()) {
|
||||
if (StringUtils.isNotBlank(onlineUser.getContactsid())) {
|
||||
for (final Contacts contact : contacts) {
|
||||
@ -193,7 +195,7 @@ public class AppsController extends Handler {
|
||||
Page<OnlineUser> onlineUserList = this.onlineUserRes.findByOrgiAndStatus(
|
||||
super.getOrgi(request), MainContext.OnlineUserStatusEnum.ONLINE.toString(),
|
||||
PageRequest.of(super.getP(request), super.getPs(request), Sort.Direction.DESC, "createtime"));
|
||||
List<String> ids = new ArrayList<String>();
|
||||
List<String> ids = new ArrayList<>();
|
||||
for (OnlineUser onlineUser : onlineUserList.getContent()) {
|
||||
onlineUser.setBetweentime((int) (System.currentTimeMillis() - onlineUser.getLogintime().getTime()));
|
||||
if (StringUtils.isNotBlank(onlineUser.getContactsid())) {
|
||||
@ -201,7 +203,7 @@ public class AppsController extends Handler {
|
||||
}
|
||||
}
|
||||
if (ids.size() > 0) {
|
||||
Iterable<Contacts> contactsList = contactsRes.findAll(ids);
|
||||
Iterable<Contacts> contactsList = contactsRes.findAllById(ids);
|
||||
for (OnlineUser onlineUser : onlineUserList.getContent()) {
|
||||
if (StringUtils.isNotBlank(onlineUser.getContactsid())) {
|
||||
for (Contacts contacts : contactsList) {
|
||||
@ -228,13 +230,14 @@ public class AppsController extends Handler {
|
||||
|
||||
@RequestMapping({"/apps/profile/save"})
|
||||
@Menu(type = "apps", subtype = "content")
|
||||
public ModelAndView profile(ModelMap map, HttpServletRequest request, @Valid User user, @Valid String index) {
|
||||
User tempUser = userRes.getOne(user.getId());
|
||||
public ModelAndView profile(HttpServletRequest request, @Valid User user, @Valid String index) {
|
||||
Optional<User> optional = userRes.findById(user.getId());
|
||||
final User logined = super.getUser(request);
|
||||
// 用户名不可修改
|
||||
user.setUsername(logined.getUsername());
|
||||
|
||||
if (tempUser != null) {
|
||||
if (optional.isPresent()) {
|
||||
User tempUser = optional.get();
|
||||
String msg = userProxy.validUserUpdate(user, tempUser);
|
||||
if (StringUtils.isNotBlank(msg) && (!StringUtils.equals(msg, "edit_user_success"))) {
|
||||
// 处理异常返回
|
||||
@ -268,9 +271,8 @@ public class AppsController extends Handler {
|
||||
tempUser.setRoleList(sessionUser.getRoleList());
|
||||
tempUser.setRoleAuthMap(sessionUser.getRoleAuthMap());
|
||||
tempUser.setAffiliates(sessionUser.getAffiliates());
|
||||
User u = tempUser;
|
||||
u.setOrgi(super.getOrgi(request));
|
||||
super.setUser(request, u);
|
||||
tempUser.setOrgi(super.getOrgi(request));
|
||||
super.setUser(request, tempUser);
|
||||
//切换成非坐席 判断是否坐席 以及 是否有对话
|
||||
if (!user.isAgent()) {
|
||||
AgentStatus agentStatus = cache.findOneAgentStatusByAgentnoAndOrig(
|
||||
@ -294,9 +296,6 @@ public class AppsController extends Handler {
|
||||
|
||||
/**
|
||||
* 获取当前产品下人员信息
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
private List<User> getUsers(HttpServletRequest request) {
|
||||
List<User> userList;
|
||||
|
@ -19,8 +19,9 @@ package com.chatopera.cc.controller.resource;
|
||||
import com.chatopera.cc.controller.Handler;
|
||||
import com.chatopera.cc.persistence.es.ContactsRepository;
|
||||
import com.chatopera.cc.util.Menu;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -30,14 +31,15 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
|
||||
@Controller
|
||||
public class ContactsResourceController extends Handler{
|
||||
@RequiredArgsConstructor
|
||||
public class ContactsResourceController extends Handler {
|
||||
|
||||
@Autowired
|
||||
private ContactsRepository contactsRes ;
|
||||
@NonNull
|
||||
private final ContactsRepository contactsRes;
|
||||
|
||||
@RequestMapping("/res/contacts")
|
||||
@Menu(type = "res" , subtype = "contacts")
|
||||
public ModelAndView add(ModelMap map , HttpServletRequest request , @Valid String q) {
|
||||
@Menu(type = "res", subtype = "contacts")
|
||||
public ModelAndView add(ModelMap map, HttpServletRequest request, @Valid String q) {
|
||||
if (q == null) {
|
||||
q = "";
|
||||
}
|
||||
|
@ -1,51 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.persistence.es;
|
||||
|
||||
import com.chatopera.cc.model.Contacts;
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ContactsRepository extends ElasticsearchRepository<Contacts, String>, ContactsEsCommonRepository {
|
||||
|
||||
int countByDatastatusIsFalseAndPhoneAndOrgi(String phone, String orgi);
|
||||
|
||||
List<Contacts> findOneByDatastatusIsFalseAndPhoneAndOrgi(String phone, String orgi);
|
||||
|
||||
Contacts findOneByWluidAndWlsidAndWlcidAndDatastatus(String wluid, String wlsid, String wlcid, Boolean datastatus);
|
||||
|
||||
List<Contacts> findByskypeidAndDatastatus(String skypeid, Boolean datastatus);
|
||||
|
||||
Contacts findByskypeidAndOrgiAndDatastatus(String skypeid, String orgi, Boolean datastatus);
|
||||
|
||||
@Query(value = "SELECT * FROM uk_contacts WHERE skypeid = ?1 AND datastatus = ?2 LIMIT 1", nativeQuery = true)
|
||||
Contacts findOneBySkypeidAndDatastatus(String skypeid, boolean datastatus);
|
||||
|
||||
List<Contacts> findByidAndDatastatus(String id, Boolean datastatus);
|
||||
|
||||
Contacts findByidAndOrgiAndDatastatus(String id, String orgi, Boolean datastatus);
|
||||
|
||||
@Query(value = "select u from uk_contacts u where u.skypeid = ?1")
|
||||
List<Contacts> findByskypeid(String skypeid);
|
||||
|
||||
@Query(value = "SELECT * FROM uk_contacts WHERE id = ?1", nativeQuery = true)
|
||||
Optional<Contacts> findOneById(final String id);
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.persistence.es;
|
||||
|
||||
import com.chatopera.cc.model.Contacts;
|
||||
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@SuppressWarnings({"unused", "SqlResolve", "JpaQlInspection"})
|
||||
public interface ContactsRepository extends ElasticsearchRepository<Contacts, String>, ContactsEsCommonRepository {
|
||||
|
||||
int countByDatastatusIsFalseAndPhoneAndOrgi(String phone, String orgi);
|
||||
|
||||
List<Contacts> findOneByDatastatusIsFalseAndPhoneAndOrgi(String phone, String orgi);
|
||||
|
||||
Contacts findOneByWluidAndWlsidAndWlcidAndDatastatus(String wluid, String wlsid, String wlcid, Boolean datastatus);
|
||||
|
||||
List<Contacts> findByskypeidAndDatastatus(String skypeid, Boolean datastatus);
|
||||
|
||||
Contacts findByskypeidAndOrgiAndDatastatus(String skypeid, String orgi, Boolean datastatus);
|
||||
|
||||
@Query(value = "SELECT * FROM uk_contacts WHERE skypeid = ?1 AND datastatus = ?2 LIMIT 1", nativeQuery = true)
|
||||
Contacts findOneBySkypeidAndDatastatus(String skypeid, boolean datastatus);
|
||||
|
||||
List<Contacts> findByidAndDatastatus(String id, Boolean datastatus);
|
||||
|
||||
Contacts findByidAndOrgiAndDatastatus(String id, String orgi, Boolean datastatus);
|
||||
|
||||
@Query(value = "select u from uk_contacts u where u.skypeid = ?1")
|
||||
List<Contacts> findByskypeid(String skypeid);
|
||||
|
||||
@Query(value = "SELECT * FROM uk_contacts WHERE id = ?1", nativeQuery = true)
|
||||
Optional<Contacts> findOneById(final String id);
|
||||
|
||||
}
|
||||
|
@ -1,40 +1,39 @@
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.util.dsdata.process;
|
||||
|
||||
import com.chatopera.cc.model.Contacts;
|
||||
import com.chatopera.cc.persistence.es.ContactsRepository;
|
||||
|
||||
public class ContactsProcess implements JPAProcess{
|
||||
|
||||
private ContactsRepository contactsRes ;
|
||||
|
||||
public ContactsProcess(ContactsRepository contactsRes){
|
||||
this.contactsRes = contactsRes ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(Object data) {
|
||||
contactsRes.save((Contacts)data) ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (C) 2017 优客服-多渠道客服系统
|
||||
* Modifications copyright (C) 2018-2019 Chatopera Inc, <https://www.chatopera.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.chatopera.cc.util.dsdata.process;
|
||||
|
||||
import com.chatopera.cc.model.Contacts;
|
||||
import com.chatopera.cc.persistence.es.ContactsRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class ContactsProcess implements JPAProcess {
|
||||
@NonNull
|
||||
private final ContactsRepository contactsRes;
|
||||
|
||||
@Override
|
||||
public void process(Object data) {
|
||||
contactsRes.save((Contacts) data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user