mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-05 20:41:34 +08:00
Fix TagRepository related class
This commit is contained in:
parent
3b039cce3c
commit
226171df3d
@ -19,24 +19,22 @@ package com.chatopera.cc.controller.api;
|
|||||||
import com.chatopera.cc.basic.MainContext;
|
import com.chatopera.cc.basic.MainContext;
|
||||||
import com.chatopera.cc.controller.Handler;
|
import com.chatopera.cc.controller.Handler;
|
||||||
import com.chatopera.cc.controller.api.request.RestUtils;
|
import com.chatopera.cc.controller.api.request.RestUtils;
|
||||||
import com.chatopera.cc.exception.CSKefuRestException;
|
|
||||||
import com.chatopera.cc.model.Tag;
|
import com.chatopera.cc.model.Tag;
|
||||||
import com.chatopera.cc.model.TagRelation;
|
import com.chatopera.cc.model.TagRelation;
|
||||||
import com.chatopera.cc.persistence.repository.TagRelationRepository;
|
import com.chatopera.cc.persistence.repository.TagRelationRepository;
|
||||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||||
import com.chatopera.cc.persistence.repository.UserRepository;
|
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
import com.chatopera.cc.util.json.GsonTools;
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
@ -51,26 +49,20 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/contacts/tags")
|
@RequestMapping("/api/contacts/tags")
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class ApiContactTagsController extends Handler {
|
public class ApiContactTagsController extends Handler {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ApiContactTagsController.class);
|
private static final Logger logger = LoggerFactory.getLogger(ApiContactTagsController.class);
|
||||||
private static final String TAGTYPE_USER = "user";
|
private static final String TAGTYPE_USER = "user";
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private final TagRepository tagRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private TagRepository tagRes;
|
private final TagRelationRepository tagRelationRes;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private TagRelationRepository tagRelationRes;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private UserRepository userRes;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取联系人标签
|
* 获取联系人标签
|
||||||
*
|
|
||||||
* @param j
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private JsonObject fetch(JsonObject j) {
|
private JsonObject fetch(JsonObject j) {
|
||||||
JsonObject resp = new JsonObject();
|
JsonObject resp = new JsonObject();
|
||||||
@ -78,7 +70,7 @@ public class ApiContactTagsController extends Handler {
|
|||||||
String contactid = j.get("contactid").getAsString();
|
String contactid = j.get("contactid").getAsString();
|
||||||
// 获取联系人所有标签
|
// 获取联系人所有标签
|
||||||
List<TagRelation> rels = tagRelationRes.findByUserid(contactid);
|
List<TagRelation> rels = tagRelationRes.findByUserid(contactid);
|
||||||
HashMap<String, String> tagged = new HashMap<String, String>();
|
HashMap<String, String> tagged = new HashMap<>();
|
||||||
|
|
||||||
for (TagRelation t : rels) {
|
for (TagRelation t : rels) {
|
||||||
tagged.put(t.getTagid(), t.getId());
|
tagged.put(t.getTagid(), t.getId());
|
||||||
@ -114,9 +106,6 @@ public class ApiContactTagsController extends Handler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建联系人标签关系
|
* 创建联系人标签关系
|
||||||
*
|
|
||||||
* @param j
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private JsonObject create(JsonObject j) {
|
private JsonObject create(JsonObject j) {
|
||||||
JsonObject resp = new JsonObject();
|
JsonObject resp = new JsonObject();
|
||||||
@ -135,9 +124,8 @@ public class ApiContactTagsController extends Handler {
|
|||||||
|
|
||||||
final String tagId = j.get("tagId").getAsString();
|
final String tagId = j.get("tagId").getAsString();
|
||||||
final String contactid = j.get("contactid").getAsString();
|
final String contactid = j.get("contactid").getAsString();
|
||||||
Tag tag = tagRes.findOne(tagId);
|
|
||||||
|
|
||||||
if (tag == null) {
|
if (!tagRes.existsById(tagId)) {
|
||||||
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_2);
|
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_2);
|
||||||
resp.addProperty(RestUtils.RESP_KEY_ERROR, "不存在该标签。");
|
resp.addProperty(RestUtils.RESP_KEY_ERROR, "不存在该标签。");
|
||||||
return resp;
|
return resp;
|
||||||
@ -161,9 +149,6 @@ public class ApiContactTagsController extends Handler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 去掉标签
|
* 去掉标签
|
||||||
*
|
|
||||||
* @param j
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private JsonObject remove(JsonObject j) {
|
private JsonObject remove(JsonObject j) {
|
||||||
JsonObject resp = new JsonObject();
|
JsonObject resp = new JsonObject();
|
||||||
@ -173,14 +158,14 @@ public class ApiContactTagsController extends Handler {
|
|||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
TagRelation t = tagRelationRes.findOne(j.get("xid").getAsString());
|
String tagId = j.get("xid").getAsString();
|
||||||
if (t == null) {
|
if (!tagRelationRes.existsById(tagId)) {
|
||||||
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
|
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
|
||||||
resp.addProperty(RestUtils.RESP_KEY_ERROR, "该联系人没有打这个标签。");
|
resp.addProperty(RestUtils.RESP_KEY_ERROR, "该联系人没有打这个标签。");
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
tagRelationRes.delete(t);
|
tagRelationRes.deleteById(tagId);
|
||||||
JsonObject data = new JsonObject();
|
JsonObject data = new JsonObject();
|
||||||
data.addProperty("msg", "删除成功。");
|
data.addProperty("msg", "删除成功。");
|
||||||
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
|
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_SUCC);
|
||||||
@ -191,8 +176,8 @@ public class ApiContactTagsController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST)
|
@RequestMapping(method = RequestMethod.POST)
|
||||||
@Menu(type = "apps", subtype = "contacttags", access = true)
|
@Menu(type = "apps", subtype = "contacttags", access = true)
|
||||||
public ResponseEntity<String> operations(HttpServletRequest request, @RequestBody final String body) throws CSKefuRestException, GsonTools.JsonObjectExtensionConflictException {
|
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("[contact tags] operations payload {}", j.toString());
|
logger.info("[contact tags] operations payload {}", j.toString());
|
||||||
JsonObject json = new JsonObject();
|
JsonObject json = new JsonObject();
|
||||||
HttpHeaders headers = RestUtils.header();
|
HttpHeaders headers = RestUtils.header();
|
||||||
@ -219,7 +204,7 @@ public class ApiContactTagsController extends Handler {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ResponseEntity<String>(json.toString(), headers, HttpStatus.OK);
|
return new ResponseEntity<>(json.toString(), headers, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,24 +18,23 @@ package com.chatopera.cc.controller.api;
|
|||||||
|
|
||||||
import com.chatopera.cc.controller.Handler;
|
import com.chatopera.cc.controller.Handler;
|
||||||
import com.chatopera.cc.controller.api.request.RestUtils;
|
import com.chatopera.cc.controller.api.request.RestUtils;
|
||||||
import com.chatopera.cc.exception.CSKefuRestException;
|
|
||||||
import com.chatopera.cc.model.Tag;
|
import com.chatopera.cc.model.Tag;
|
||||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
import com.chatopera.cc.util.json.GsonTools;
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
@ -49,18 +48,15 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/repo/tags")
|
@RequestMapping("/api/repo/tags")
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class ApiTagsController extends Handler {
|
public class ApiTagsController extends Handler {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ApiTagsController.class);
|
private static final Logger logger = LoggerFactory.getLogger(ApiTagsController.class);
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private TagRepository tagRes;
|
private final TagRepository tagRes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取标签
|
* 获取标签
|
||||||
*
|
|
||||||
* @param j
|
|
||||||
* @param request
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private JsonObject fetch(final JsonObject j, final HttpServletRequest request) {
|
private JsonObject fetch(final JsonObject j, final HttpServletRequest request) {
|
||||||
JsonObject resp = new JsonObject();
|
JsonObject resp = new JsonObject();
|
||||||
@ -97,17 +93,11 @@ public class ApiTagsController extends Handler {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 联系人标签
|
* 联系人标签
|
||||||
*
|
|
||||||
* @param request
|
|
||||||
* @param body
|
|
||||||
* @return
|
|
||||||
* @throws CSKefuRestException
|
|
||||||
* @throws GsonTools.JsonObjectExtensionConflictException
|
|
||||||
*/
|
*/
|
||||||
@RequestMapping(method = RequestMethod.POST)
|
@RequestMapping(method = RequestMethod.POST)
|
||||||
@Menu(type = "apps", subtype = "tags", access = true)
|
@Menu(type = "apps", subtype = "tags", access = true)
|
||||||
public ResponseEntity<String> operations(HttpServletRequest request, @RequestBody final String body) throws CSKefuRestException, GsonTools.JsonObjectExtensionConflictException {
|
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("[contact tags] operations payload {}", j.toString());
|
logger.info("[contact tags] operations payload {}", j.toString());
|
||||||
JsonObject json = new JsonObject();
|
JsonObject json = new JsonObject();
|
||||||
HttpHeaders headers = RestUtils.header();
|
HttpHeaders headers = RestUtils.header();
|
||||||
@ -118,17 +108,14 @@ public class ApiTagsController extends Handler {
|
|||||||
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_1);
|
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_1);
|
||||||
json.addProperty(RestUtils.RESP_KEY_ERROR, "不合法的请求参数。");
|
json.addProperty(RestUtils.RESP_KEY_ERROR, "不合法的请求参数。");
|
||||||
} else {
|
} else {
|
||||||
switch (StringUtils.lowerCase(j.get("ops").getAsString())) {
|
if ("fetch".equals(StringUtils.lowerCase(j.get("ops").getAsString()))) {
|
||||||
case "fetch":
|
|
||||||
json = fetch(j, request);
|
json = fetch(j, request);
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
|
json.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_3);
|
||||||
json.addProperty(RestUtils.RESP_KEY_ERROR, "不支持的操作。");
|
json.addProperty(RestUtils.RESP_KEY_ERROR, "不支持的操作。");
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new ResponseEntity<String>(json.toString(), headers, HttpStatus.OK);
|
return new ResponseEntity<>(json.toString(), headers, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,11 @@ import com.chatopera.cc.persistence.repository.TagRepository;
|
|||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
import com.chatopera.cc.util.RestResult;
|
import com.chatopera.cc.util.RestResult;
|
||||||
import com.chatopera.cc.util.RestResultType;
|
import com.chatopera.cc.util.RestResultType;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@ -39,17 +40,17 @@ import javax.validation.Valid;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/tags")
|
@RequestMapping("/api/tags")
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class UkefuApiTagsController extends Handler {
|
public class UkefuApiTagsController extends Handler {
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private TagRepository tagRes;
|
private final TagRepository tagRes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按照分类获取标签列表
|
* 按照分类获取标签列表
|
||||||
* 按照分类获取标签列表,Type 参数类型来自于 枚举,可选值目前有三个 : user workorders summary
|
* 按照分类获取标签列表,Type 参数类型来自于 枚举,可选值目前有三个 : user workorders summary
|
||||||
* @param request
|
*
|
||||||
* @param type 类型
|
* @param type 类型
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
@RequestMapping(method = RequestMethod.GET)
|
@RequestMapping(method = RequestMethod.GET)
|
||||||
@Menu(type = "apps", subtype = "tags", access = true)
|
@Menu(type = "apps", subtype = "tags", access = true)
|
||||||
|
@ -29,7 +29,8 @@ import com.chatopera.cc.persistence.repository.QualityRepository;
|
|||||||
import com.chatopera.cc.persistence.repository.SessionConfigRepository;
|
import com.chatopera.cc.persistence.repository.SessionConfigRepository;
|
||||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -42,22 +43,23 @@ import java.util.List;
|
|||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/apps/quality")
|
@RequestMapping("/apps/quality")
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class AgentQualityController extends Handler {
|
public class AgentQualityController extends Handler {
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private ACDPolicyService acdPolicyService;
|
private final ACDPolicyService acdPolicyService;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private QualityRepository qualityRes;
|
private final QualityRepository qualityRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private SessionConfigRepository sessionConfigRes;
|
private final SessionConfigRepository sessionConfigRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private TagRepository tagRes;
|
private final TagRepository tagRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private Cache cache;
|
private final Cache cache;
|
||||||
|
|
||||||
@RequestMapping(value = "/index")
|
@RequestMapping(value = "/index")
|
||||||
@Menu(type = "agent", subtype = "quality")
|
@Menu(type = "agent", subtype = "quality")
|
||||||
@ -71,13 +73,13 @@ public class AgentQualityController extends Handler {
|
|||||||
|
|
||||||
@RequestMapping(value = "/save")
|
@RequestMapping(value = "/save")
|
||||||
@Menu(type = "agent", subtype = "quality")
|
@Menu(type = "agent", subtype = "quality")
|
||||||
public ModelAndView save(ModelMap map, HttpServletRequest request, @Valid QualityRequest qualityArray) {
|
public ModelAndView save(HttpServletRequest request, @Valid QualityRequest qualityArray) {
|
||||||
String orgi = super.getOrgi(request);
|
String orgi = super.getOrgi(request);
|
||||||
|
|
||||||
if (qualityArray != null && qualityArray.getTitle() != null) {
|
if (qualityArray != null && qualityArray.getTitle() != null) {
|
||||||
List<Quality> qualityList = qualityRes.findByQualitytypeAndOrgi(MainContext.QualityType.CHAT.toString(), super.getOrgi(request));
|
List<Quality> qualityList = qualityRes.findByQualitytypeAndOrgi(MainContext.QualityType.CHAT.toString(), super.getOrgi(request));
|
||||||
qualityRes.delete(qualityList);
|
qualityRes.deleteAll(qualityList);
|
||||||
List<Quality> tempList = new ArrayList<Quality>();
|
List<Quality> tempList = new ArrayList<>();
|
||||||
for (int i = 0; i < qualityArray.getTitle().length; i++) {
|
for (int i = 0; i < qualityArray.getTitle().length; i++) {
|
||||||
Quality temp = new Quality();
|
Quality temp = new Quality();
|
||||||
temp.setName(qualityArray.getTitle()[i]);
|
temp.setName(qualityArray.getTitle()[i]);
|
||||||
@ -92,7 +94,7 @@ public class AgentQualityController extends Handler {
|
|||||||
tempList.add(temp);
|
tempList.add(temp);
|
||||||
}
|
}
|
||||||
if (tempList.size() > 0) {
|
if (tempList.size() > 0) {
|
||||||
qualityRes.save(tempList);
|
qualityRes.saveAll(tempList);
|
||||||
}
|
}
|
||||||
SessionConfig config = acdPolicyService.initSessionConfig(super.getOrgi(request));
|
SessionConfig config = acdPolicyService.initSessionConfig(super.getOrgi(request));
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
@ -106,12 +108,12 @@ public class AgentQualityController extends Handler {
|
|||||||
cache.putSessionConfigByOrgi(config, orgi);
|
cache.putSessionConfigByOrgi(config, orgi);
|
||||||
cache.deleteSessionConfigListByOrgi(orgi);
|
cache.deleteSessionConfigListByOrgi(orgi);
|
||||||
}
|
}
|
||||||
if (qualityArray != null && qualityArray.getTag() != null && qualityArray.getTag().length > 0) {
|
if (qualityArray.getTag() != null && qualityArray.getTag().length > 0) {
|
||||||
List<Tag> tagList = tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.TagType.QUALITY.toString());
|
List<Tag> tagList = tagRes.findByOrgiAndTagtype(super.getOrgi(request), MainContext.TagType.QUALITY.toString());
|
||||||
if (tagList.size() > 0) {
|
if (tagList.size() > 0) {
|
||||||
tagRes.delete(tagList);
|
tagRes.deleteAll(tagList);
|
||||||
}
|
}
|
||||||
List<Tag> tagTempList = new ArrayList<Tag>();
|
List<Tag> tagTempList = new ArrayList<>();
|
||||||
for (String tag : qualityArray.getTag()) {
|
for (String tag : qualityArray.getTag()) {
|
||||||
Tag temp = new Tag();
|
Tag temp = new Tag();
|
||||||
temp.setOrgi(super.getOrgi(request));
|
temp.setOrgi(super.getOrgi(request));
|
||||||
@ -122,7 +124,7 @@ public class AgentQualityController extends Handler {
|
|||||||
tagTempList.add(temp);
|
tagTempList.add(temp);
|
||||||
}
|
}
|
||||||
if (tagTempList.size() > 0) {
|
if (tagTempList.size() > 0) {
|
||||||
tagRes.save(tagTempList);
|
tagRes.saveAll(tagTempList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,11 @@ import com.chatopera.cc.persistence.repository.AttachmentRepository;
|
|||||||
import com.chatopera.cc.persistence.repository.KbsTypeRepository;
|
import com.chatopera.cc.persistence.repository.KbsTypeRepository;
|
||||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||||
import com.chatopera.cc.util.Menu;
|
import com.chatopera.cc.util.Menu;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.ModelMap;
|
import org.springframework.ui.ModelMap;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@ -47,26 +48,27 @@ import java.util.Date;
|
|||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping({"/apps/kbs"})
|
@RequestMapping({"/apps/kbs"})
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class KbsController extends Handler {
|
public class KbsController extends Handler {
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private TagRepository tagRes;
|
private final TagRepository tagRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private KbsTypeRepository kbsTypeRes;
|
private final KbsTypeRepository kbsTypeRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private KbsTopicRepository kbsTopicRes;
|
private final KbsTopicRepository kbsTopicRes;
|
||||||
|
|
||||||
@Autowired
|
@NonNull
|
||||||
private AttachmentRepository attachementRes;
|
private final AttachmentRepository attachementRes;
|
||||||
|
|
||||||
@Value("${web.upload-path}")
|
@Value("${web.upload-path}")
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
@RequestMapping({"/index"})
|
@RequestMapping({"/index"})
|
||||||
@Menu(type = "apps", subtype = "kbs")
|
@Menu(type = "apps", subtype = "kbs")
|
||||||
public ModelAndView index(ModelMap map, HttpServletRequest request) {
|
public ModelAndView index() {
|
||||||
return request(super.createAppsTempletResponse("/apps/business/kbs/index"));
|
return request(super.createAppsTempletResponse("/apps/business/kbs/index"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +164,8 @@ public class KbsController extends Handler {
|
|||||||
} else {
|
} else {
|
||||||
attachmentFile.setTitle(file.getOriginalFilename());
|
attachmentFile.setTitle(file.getOriginalFilename());
|
||||||
}
|
}
|
||||||
if (!StringUtils.isBlank(attachmentFile.getFiletype()) && attachmentFile.getFiletype().indexOf("image") >= 0) {
|
String filetype = attachmentFile.getFiletype();
|
||||||
|
if (!StringUtils.isBlank(filetype) && filetype.contains("image")) {
|
||||||
attachmentFile.setImage(true);
|
attachmentFile.setImage(true);
|
||||||
}
|
}
|
||||||
attachmentFile.setFileid(fileid);
|
attachmentFile.setFileid(fileid);
|
||||||
|
@ -19,16 +19,18 @@ package com.chatopera.cc.persistence.impl;
|
|||||||
import com.chatopera.cc.model.Tag;
|
import com.chatopera.cc.model.Tag;
|
||||||
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
|
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
|
||||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service("servicedata")
|
@Service("servicedata")
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class ServiceDataExchangeImpl implements DataExchangeInterface {
|
public class ServiceDataExchangeImpl implements DataExchangeInterface {
|
||||||
@Autowired
|
@NonNull
|
||||||
private TagRepository tagRes ;
|
private final TagRepository tagRes;
|
||||||
|
|
||||||
public String getDataByIdAndOrgi(String id, String orgi) {
|
public String getDataByIdAndOrgi(String id, String orgi) {
|
||||||
Tag tag = tagRes.findByOrgiAndId(orgi, id);
|
Tag tag = tagRes.findByOrgiAndId(orgi, id);
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
package com.chatopera.cc.persistence.impl;
|
package com.chatopera.cc.persistence.impl;
|
||||||
|
|
||||||
import com.chatopera.cc.model.Tag;
|
import com.chatopera.cc.model.Tag;
|
||||||
import com.chatopera.cc.model.User;
|
|
||||||
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
|
import com.chatopera.cc.persistence.interfaces.DataExchangeInterface;
|
||||||
import com.chatopera.cc.persistence.repository.TagRepository;
|
import com.chatopera.cc.persistence.repository.TagRepository;
|
||||||
import com.chatopera.cc.persistence.repository.UserRepository;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service("tagdata")
|
@Service("tagdata")
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class TagDataExchangeImpl implements DataExchangeInterface {
|
public class TagDataExchangeImpl implements DataExchangeInterface {
|
||||||
@Autowired
|
@NonNull
|
||||||
private TagRepository tagRes;
|
private final TagRepository tagRes;
|
||||||
|
|
||||||
public String getDataByIdAndOrgi(String id, String orgi) {
|
public String getDataByIdAndOrgi(String id, String orgi) {
|
||||||
Tag tag = tagRes.findByOrgiAndId(orgi, id);
|
Tag tag = tagRes.findByOrgiAndId(orgi, id);
|
||||||
|
@ -25,8 +25,7 @@ import org.springframework.data.repository.query.Param;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface TagRepository extends JpaRepository<Tag, String>
|
public interface TagRepository extends JpaRepository<Tag, String> {
|
||||||
{
|
|
||||||
|
|
||||||
Tag findByOrgiAndTag(String orgi, String tag);
|
Tag findByOrgiAndTag(String orgi, String tag);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user